Showing posts with label JOSH. Show all posts
Showing posts with label JOSH. Show all posts

March 16, 2018

Josh : playtime with array

Question:Sorted Array have given to you.now a hacker swap odd index value with other odd index value.WAP that serach the element and return it's index in logn complexity.
Example: original sorted  array :{1,2,3,4,5,6,7,8}
              swapped given array:{1,4,3,2,5,8,7,6},key,5(element for searching)
              Output 4(it's index).

April 3, 2015

JOSH :Diameter of a Binary Tree


Question: WAP that find out longest Diameter of Tree. The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two leaves in the tree.

March 21, 2015

JOSH:Question: WAP that sum up all one child parent nodes without globle variable


//Question: WAP that sum up all one child parent nodes without globle variable
//             3
//            / \
//          4    5
//         / \   \
//        6   8    9
//            /
//           7
//output 8+5=13

March 18, 2015

JOSH: WAP that sum up all leaf nodes without globle variable

Question

WAP that sum up all leaf nodes without globle
input tree  3
           / \
         4    5
        / \    \
       6   8    9
          /
         7
Output 6+7+9=22

March 15, 2015

JOSH:Merge two sorted array(first in asc,second dec) into array in ascending order

Solution:
 Merge two sorted array into new sorrted array
input A 1,2,3,4,5(asc)
input B 10,9,8,7,6(dec)
output 1,2,3,4,5,6,7,8,9,10(asc)