logo

CuriousTab

CuriousTab

Discussion


Home Interview Technology Comments

  • Question
  • Write an algorithm to separate all ones & zeroes in an array.


  • Correct Answer
  • 1 Have two indexes pointing to two ends of array, say i and j 2 Approach towards each other with a check condition that they dont cross each other 3 Each iteration of while loop, swap the numbers pointed by two indexes when num[i] index number is not equal to 1 void sort() { int a[]={1,0,0,0,1,1,0,1,0,1,0,0,1,0}; int i=0; int j=13; int temp; while(j>i) { if(a[i]==1) i++; if(a[j]==0) j--; if(a[i]==0) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } for(i=0;i<14;i++) ConsoleWrite(a[i]+", "); } Output: 1,1,1,1,1,1,0,0,0,0,0,0,0 


  • Technology problems


    Search Results


    • 1. Define stored procedure. What are its advantages and disadvantages?
    • Discuss
    • 2. What are the different types of system calls?
    • Discuss
    • 3. What exactly do you mean by UDP?
    • Discuss
    • 4. Explain the basic difference between 32-bit and 64-bit operating system?
    • Discuss
    • 5. What is dual-boot system?
    • Discuss
    • 6. How would you reverse a doubly-linked list?
    • Discuss
    • 7. Write a method to fill all the spaces in a string with '%20'
    • Discuss
    • 8. Difference between system call and API
    • Discuss
    • 9. What is Marshalling?
    • Discuss
    • 10. How do you handle errors in CICS programs?
    • Discuss


    Comments

    There are no comments.

Enter a new Comment