The <http://www.algo-faq.com/index.php> gives very nice implementations of several algorithm
Linked List
- Declare the structure of Linked List
- Find the middle node of a linked list
- Display a linked list backwards.
- How to free nodes of a linked list
- Find all the common elements from two sorted link list
- Find the nth node from end of a linked list.
- Device an algorithm to reverse a linked list iteratively.
- Device an algorithm to reverse a linked list recursively.
- Given a sorted linked list , insert a node in it such that after insertion , the linked list is still in sorted order.
- Remove all duplicates from a sorted linked list.
- 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
- How will you reduce the number of comparisons in binary search over an array.
- How can you reduce the number of comparisons in linear search.
- Implement binary search in Linked list
Bitwise Operators
- Find out the number of set-bits in an integer.
- Using bitwise operators , determine if a number is a power of 2.
- Increment a number without any arithmetic operator.
- Invert all odd bits of an integer.
- Given two numbers , find out the number of bits they differ in.
- Given a number reverse its bits.
- Round a number to the next power of 2
Misc
- Calculate X^N ( X raised to power N) in order O(lgN) time.
- Given a number , determine its square root.
- Increment a number without any arithmetic operator.
- Find out if a machine is big-endian or little-endian.
- Swap two variables without using a third variable.
- Find the maximum of three numbers in one line using conditional ( ternary) operators.
- Find out if a given number is an Armstrong number
- Given X1...N ,determine Y1...N ,Where Yi = X1...i-1,i+1...N without using division operator.
- Various approaches to find out the nth Fibonacci number.
- Given two rectangles , determine if they intersect.
♥ ¸¸.•*¨*•♫♪♪♫•*¨*•.¸¸♥
No comments:
Post a Comment