Check if a given array can represent Preorder Traversal of Binary Search Tree. OR Check if given Preorder traversal is valid BST (Binary Search Tree).OR Given an array of numbers, verify whether it is the correct Preorder traversal sequence of a binary search tree.
You are given an array of numbers which represents Preorder traversal of Binary Search Tree. Verify whether it is a correct Preorder sequence or not.
Lets understand what is the input and the expected output.
Given a Linked list, Sort it using Merge Sort Algorithm.
Merge sort is preferred algorithm for sorting a linked list, lets see why, The way linked list is structured which doesn't allow random access makes some other algorithms like Quicksort perform poorly, So Merge sort is often preferred algorithm for sorting linked list. Lets understand what is the input and the expected output.
Lets understand what is the input and the expected output.
So the question is, You have given a 3 Peg (Start peg, Auxiliary/helper peg and End Peg) Start peg contains 3 disks of different sizes as shown. You have to move all the disk from Start peg to End peg using Auxiliary peg.
There are few rules that need to keep in mind, 1. Only one disk can be moved at a time. 2. Large size disk can't be placed on top of small sized disk.
Detect loop in Linked list. Identify start node of loop in Linked list. Remove loop in Linked list.
What is Loop in Linked list?
Generally, the last node of the linked list points to NULL, which is a indication of end of list. But in Linked list containing Loop, last node instead of pointing NULL, it points to some of the internal node/starting node/itself. In this case, If we traverse the Linked list node one by one, our traversal will never ends as it goes in loop.
Check below images for better understanding on how Linked list containing loop looks like.
Hi, I am Jayesh, not a professional blogger but when time permits, love to share in-depth solutions to popular Interview questions. Any questions/feedback, Please drop an email at jayeshmaheshpatel@gmail.com