Welcome~~~


Another blog:
http://fun-st.blogspot.com/

It is easier to write an incorrect program than understand a correct one.

Sunday, February 13, 2011

Nice Resource from algo-faq

The <http://www.algo-faq.com/index.php> gives very nice implementations of several algorithm

Linked List

  1. Declare the structure of Linked List
  2. Find the middle node of a linked list
  3. Display a linked list backwards.
  4. How to free nodes of a linked list 
  5. Find all the common elements from two sorted link list
  6. Find the nth node from end of a linked list.
  7. Device an algorithm to reverse a linked list iteratively.
  8. Device an algorithm to reverse a linked list recursively.
  9. Given a sorted linked list , insert a node in it such that after insertion , the linked list is still in sorted order.
  10. Remove all duplicates from a sorted linked list.
  11. Given two sorted linked lists , create a new linked list having the common elements.

Stacks and Queues

Implementing stacks using arrays.
Implementing stacks using linked list.
Implementing Queue using arrays.

                  for this one, when en-queue, to make the re-use of the queue( it's front part) it should be data[++rear%ELEMENTS] = value;
                  Since there is the counter to check the full of the queue, don't have to worry about the overwrite.
           
Implementing Queues using linked list.
How to implement a Stack using two Queues.
How to implement a Queue using two Stacks.

Searching

  1. How will you reduce the number of comparisons in binary search over an array.
  2. How can you reduce the number of comparisons in linear search.
  3. Implement binary search in Linked list

Bitwise Operators

  1. Find out the number of set-bits in an integer.
  2. Using bitwise operators , determine if a number is a power of 2.
  3. Increment a number without any arithmetic operator.
  4. Invert all odd bits of an integer.
  5. Given two numbers , find out the number of bits they differ in.
  6. Given a number reverse its bits. 
  7. Round a number to the next power of 2

Misc

  1. Calculate X^N ( X raised to power N) in order O(lgN) time.
  2. Given a number , determine its square root. 
  3. Increment a number without any arithmetic operator.
  4. Find out if a machine is big-endian or little-endian.
  5. Swap two variables without using a third variable.
  6. Find the maximum of three numbers in one line using conditional ( ternary) operators.
  7. Find out if a given number is an Armstrong number 
  8. Given X1...N  ,determine Y1...N ,Where Yi = X1...i-1,i+1...N  without using division operator.
  9. Various approaches to find out the nth Fibonacci number.
  10. Given two rectangles , determine if they intersect.


♥ ¸¸.•*¨*•♫♪♪♫•*¨*•.¸¸♥

No comments:

Post a Comment