Tag: Data Structure
Merge two sorted arrays in Javascript
In this blog we are writing program to merge two sorted arrays in javascript. Problem : Given two sorted arrays, merge them into a new array that is also sorted. […]
Find Second largest element in an array in Javascript
This program is to find second largest element in an array in Javascript. This was asked in PaisaBazaar interview and i have solved it perfectly. So i thought to share […]
Reverse a Linked List in groups of given size using Javascript
In this post given a linked list, write a function to Reverse a Linked List in groups of given size using Javascript after every k nodes (where k is an […]
Rotate a Linked List in Javascript
In this post we are going to Rotate a Linked List in Javascript . For example, if the given linked list is 10->20->30->40->50->60 and k is 4, the list should […]
Reverse a Linked List in Javascript
In this post we are going to reverse a linked list in javascript. Input: Head of following linked list1->2->3->4->NULLOutput: Linked list should be changed to,4->3->2->1->NULL To reverse a linked list […]
Binary Tree Traversals (Inorder, Preorder and Postorder) in Javascript
In previous post we have learned about how can we create a binary search tree in javascript and tried some operations on binary tree like search a node in tree, […]
Binary Search Tree in Javascript
Binary Search Tree is node based data structure which has the below properties Left Nodes of tree is lesser than its parent node. Right Nodes of tree are greater than […]
Program for Stock Buy Sell to Maximize Profit in Javascript
The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days. For example, […]
Rearrange an array in maximum minimum form in Javascript
In a sorted array of integers, rearrange the array alternately. First element should be the maximum value, second minimum value, third-second max, fourth-second min and so on. Examples Input: arr[] […]
Find middle element in Linked List in Javascript
In this post we are going to find the middle of any Linked List . This is a very popular question ask by the interviewers . Lets start by creating […]