Wednesday, January 27, 2016

Tree Problems

  • Tree Traversals
  • Level Order Tree Traversal
  • Maximum Depth or Height of a Tree
  • Count leaf nodes in a binary tree
  • Given a binary tree, print out all of its root-to-leaf paths one per line.
  • Write a C program to Delete a Tree
  • If you are given two traversal sequences, can you construct the binary tree?
  • Print Ancestors of a given node in Binary Tree
  • Print nodes at k distance from root
  • Maximum width of a binary tree

BST:
  • Search and Insert in BST
  • Deletion from BST
  • Inorder predecessor and successor for a given key in BST
  • Lowest Common Ancestor in a Binary Search Tree
  • Find the node with minimum value in a Binary Search Tree
  • Find k-th smallest element in BST (Order Statistics in BST)

Strings Problems


  • Print Concatenation of Zig-Zag String in ‘n’ Rows
  • Check if edit distance between two strings is one
  • Reverse an array without affecting special characters
  • Length of the longest valid substring
  • Check if two given strings are isomorphic to each other
  • Given a string, print all possible palindromic partitions
  • Transform One String to Another using Minimum Number of Given Operation
  • Remove spaces from a given string

Tuesday, January 26, 2016

Linked List Problems

  • Linked List Insertion
  • Linked List Deletion (Deleting a given key)
  • Linked List Deletion (Deleting a key at given position) [ Ans ]
  • Find Length of a Linked List (Iterative and Recursive) [ Ans ]
  • Search an element in a Linked List (Iterative and Recursive) [ Ans ]
  • Swap nodes in a linked list without swapping data [ Ans ]
  • Write a C function to print the middle of a given linked list [ Ans ]
  • Nth node from the end of a Linked List [ Ans ]
  • Write a function to delete a Linked List [ Ans ]
  • Reverse a linked list
  • Detect loop in a linked list [ Ans ]
  • Given only a pointer to a node to be deleted in a singly linked list, how do you delete it?
  • Function to check if a singly linked list is palindrome
  • Recursive function to print reverse of a Linked List
  • Union and Intersection of two Linked Lists
  • Detect and Remove Loop in a Linked List

Monday, January 25, 2016

Arrays Problems

1. Find the missing number in Arithmetic Progression  [ Check ]

2. Given an array A[] and a number x, check for pair in A[] with sum as x [ Check Here ]

3. Majority Element
Majority Element: A majority element in an array A[] of size n is an element that appears more than n/2 times (and hence there is at most one such element). [ Check Here ]

4. Find the Number Occurring Odd Number of Times Check Here ]
Given an array of positive integers. All numbers occur even number of times except one number which occurs odd number of times. Find the number in O(n) time & constant space.

5. Largest Sum Contiguous Subarray [ Ans ]
Write an efficient C program to find the sum of contiguous subarray within a one-dimensional array of numbers which has the largest sum.

6. Search an element in a sorted and rotated array [ Ans ]

7. Merge an array of size n into another array of size m+n [ Ans ]

8. Write a program to reverse an array or string [ Ans ]

9. Program for array rotation

10. Leaders in an array [ Ans ]
Write a program to print all the LEADERS in the array. An element is leader if it is greater than all the elements to its right side. And the rightmost element is always a leader. For example int the array {16, 17, 4, 3, 5, 2}, leaders are 17, 5 and 2.

11. Find the smallest and second smallest element in an array [ Ans ]

12. Segregate Even and Odd numbers [ Ans ]

13. Check for Majority Element in a sorted array

14. Maximum and minimum of an array using minimum number of comparisons [ Ans ]

15. Segregate 0s and 1s in an array [ Ans ]

16. Sort an array of 0s, 1s and 2s [ Ans ]

17. Find the two repeating elements in a given array [ Ans ]

18. Find duplicates in O(n) time and O(1) extra space [ Ans ]

19. Find the element that appears once [ Ans ]

20. Count 1’s in a sorted binary array [ Ans ]

21. Given a sorted array and a number x, find the pair in array whose sum is closest to x
      [ Ans ]

22. Print All Distinct Elements of a given integer array [ Ans ] ( use HashSet )

23. Find the minimum element in a sorted and rotated array [ Ans ]

24. Floor and Ceiling in a sorted array [ Ans ]

25. Union and Intersection of two sorted arrays

26. Count the number of occurrences in a sorted array

27. Maximum of all subarrays of size k (Added a O(n) method) *****

28. Find whether an array is subset of another array

29. Find the element before which all the elements are smaller than it, and after which all are greater

30. Find the odd appearing element in O(Log n) time [ Ans ]