Attribution Non-Commercial (BY-NC)

447 tayangan

Attribution Non-Commercial (BY-NC)

- The wonderful world of Tregex
- C++ practice questions.pdf
- WKP115S Activities
- SmartSketch Code
- In-memory URL Compression
- Rock Mechanics
- 4.Decision Tables
- 07a1ec04 Computer Programming
- Meljun Cortes Data Structures Types of Binary Search Tree
- DS Unit 2
- 2008 Base Paper
- Persistent 11
- Tree based Techniques for web access patterns – a survey
- c programming
- Introduction to Algorithms
- Ame
- MIT6_851S12_ps1s
- Priority queues on parallel machines
- slides12-continuations.pdf
- A DATA MINING APPROACH TO PREDICT PROSPECTIVE BUSINESS SECTORS FOR LENDING IN RETAIL BANKING USING DECISION TREE

Anda di halaman 1dari 18

The index can be like this 1. Unit 1 1.1 sub unit 1 1.2 sub unit 2 1.1.1 sub section1 1.1.2 sub secton2 1.3 sub unit 3 ex1. example1 2. unit 2 1.1.1 sub section1 3. unit 3 ex1. example1 . . . (2) You are given n sorted linked lists. Output should be a single sorted linked list. (3) program P1 has many linked programs. so to compile Program p1, p3 p4 p5 needs to be compiled. P3 requires p6,p7 to be compiled. p7 requires p5 to be compiled. . . . many such dependencies were given. Propose an efficient way to compile p1. (4) Find longest palindrome from a given string. (5) You are given a valid expression. Remove unwanted parenthesis to return another valid expression. example: (c) -this parenthesis can be removed (a+b)*c -should not be removed (a*b)+c -can be removed as operator precedence will hold. Initially I was asked to give soln considering only /, *, +, - operators. Then I had to Consider all possible operators and give a generalized solution. (6) given a BT 1 2 3 4 56 7 . . . .. . . . print ths in this fashion 1 3 2 4 5 6 7 15 14 13 12 11 10 9 8 ......

I used a Bistack and implemented using linked list I deviced an algo with 4n operations first then i revised it for jus n operations Expected time limit to solve the above problem 7 Mins (7) Given M points M>>>>large in a graph struct point { int x; int y; }points[M]; they ll give u the kth point u need to find the nearest N points to that kth point and should give the radius of the circle which would cover all this N points I solved this using a array size of N and heapification complexity of my solution was O(N lg (M-N) ) They accepted both my solns but they expect to do problems faster than we think. (8) You have a string say "foobarfoo" in which "fo" and "oo" aree repeated twice.You have to find all such repeated pairs in O(n) time,The string can only have alphanumeric elements in it. (9) Cud any1 tell me hw to implement BFS without a queue?! (10) Given a text file, implement a solution to find out if a pattern similar to wild cards can be detected. for example find if a*b*cd*, or *win or *def* exists in the text. how to take care of wild cards? (11) Imagine you have a square matrix, where each cell is filled with either black or white. Design an algorithm to find the maximum subsquare such that all four borders are filled with black pixels. (12) How will one go about extracting a random number from a bitset ? let's say i have a bitset 100000010000101000100010001 where 1 denote what numbers are currently present in the set How can one extract these ones in a random manner .Generating a random number modulo size of the bitset won't work as it can land upon a zero value as well and this , in worst case can take O(size of bitset * genarating pseudo random number) time which is very costly . Anybody knows how to do this ? (13) What is the probability that a positive integer less than 1000 has exactly two digits which are the same? OPTIONS 1)9/37 2)28/111 3)243/1000 4)63/250 5)none

(14) You are given a boolean expression consisting of a string of the symbols 'true', 'false', 'and', 'or', and 'xor'. Count the number of ways to parenthesize the expression such that it will evaluate to true. For example, there is only 1 way to parenthesize 'true and false xor true' such that it evaluates to true. (15) Design a data structure that allows one to search, insert, and deletean integer X in O (1) time in a table (i.e. constant time, independent of the total number of integers stored). Assume that 1XN. Alsoassume that the maximum number of integers in the table can only be M at any one time. You are given M+N units of space available for the table. (16) given an array how to find number of set which results to give a particular sum ( consider continues, noncontinue) both. example [5, 5, 10, 2, 3] should return 4 (5 + 10, 5 + 10, 5 + 5 + 2 + 3, 10 + 2 + 3 can we do any logical thing to computer sum if range is known?? (17) Given an integer N and an another integer n we have to write a programto find the remainder of the following problems (1! + 2! + 3! + 4! + ..................... + N!)mod(n) N<=1000000 n<=1000; (18) With a directed graph G and we want to find the cycle cover(a set of cycles s.t. every vertex is in exactly 1 cycle), can we do this in poly-time? Can we break each node into entry/exit nodes and do bipartite matching? Would this work? (19) The question is to find the length of the smallest cycle in a bipartite graph G=(V,E) (V - vertices, E edges). (20) You are given an (unsorted) set of n integers. Given some k (1 < k <= n), you are required to find and return the element of the set that has more than n/k occurrences. Return None otherwise. Required (best known) time complexity: O(n log k) (21) Given n numbers, you can perform the following operation any number of times : Choose any subset of the numbers, none of which are 0. Decrement the numbers in the subset by 1, and increment the numbers not in the subset by K. Is it possible to perform operations such that all numbers except one of them become 0 ? Input : The first line contains the number of test cases T. 2*T lines follow, 2 for each case. The first line of a test case contains the numbers n and K. The next line contains n numbers, a_1...a_n. Output : Output T lines, one corresponding to each test case. For a test case, output "YES" if there is a sequence of operations as described,and "NO" otherwise. Sample Input : 3 21 10 10

32 122 32 123 Sample Output : YES YES NO Constraints : 1 <= T <= 1000 2 <= n <= 100 1 <= K <= 10 0 <= a_i <= 1000 (22) Given an array of integers, each element represents the max number of jumps can make forward. What is the minimum number of element selections to reach the end of the array (starting from the first element). Example: arr = 1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9 Here the min # of selections is : 3 with the sequence : 1-3 -8 ->9 First element is 1, so can only go to 3. Second element is 3, so can make at most 3 jumps: eg to 5 or 8 or 9. If an element is 0, then cannot make any jumps (23) Place N number from 1 to N, in 2N positions in such a way so that there are exactly a number of cells between two placed locations of number a. Write a program to display numbers placed in this way. Example:One of the possible placement for 7 numbers in 14 positions is : 57236253471614 There are exactly five other numbers between two occurrences of 5, exactly seven other numbers between two occurrences of number 7 and the same is true for all other number placements. (24) Given 1. A 2. Ctrl+A 3. Ctrl+C 4. Ctrl+V If you can only press the keyboard for N times (with the above four keys), please write a program to produce maximum numbers of A. If possible, please also print out the sequence of keys.So the input parameter is N (No. of keys that you can press), the output is M (No. of As that you can produce). (25) Given an ancestor matrix for an binary tree where a[i][j]=1 if "i" is parentto "j", else a[i][j]=0 create the binary tree. from given ancestor matrix.

(26) If pairwise sums of 'n' numbers are given in non-decreasing order identify the individual numbers. If the sum is corrupted print -1 Example: i/p: 4 5 7 10 12 13 o/p: 1 3 4 9 (27) Write an Algorithm to Implement the Syntax highlighter what will be the complexity of algo. Which data Structure You Will Use fro that then Write a Program to Implement the Syntax highlighter Constraints: As You Type in the Editor Your Input String color should change according to slandered syntax highlighter it should happens parallel e.g as you type color automatically should change means you don't have option to say that first i will search a pattern that i have to highlight using such as KMP any String Matching Algorithm & then i will highlight that part ..no interviewer don't allow it... Again only thing to say that he is strict that it should happens simultaneously for example turbo C, Eclipse etc. (28) On Unix computers, data is stored in directories. There is one root directory, and this might have several directories contained inside of it, each with different names. These directories might have even more directories contained inside of them, and so on. A directory is uniquely identified by its name and its parent directory(the directory it is directly contained in). This is usually encoded in a path, which consists of several parts each preceded by a forward slash('/'). The final part is the name of the directory, and everything else gives the path of its parent directory. For example, consider the path:/home/facebook/people This refers to the directory with name "people" in the directory described by "/home facebook", which in turn refers to the directory with name "facebook" in the directory described by the path "/home". In this path, there is only one part, which means it refers to the directory with the name "home" in the root directory. To create a directory, you can use the mkdir command. You specify a path, and then mkdir will create the directory described by that path, but only if the parent directory already exists. For example, if you wanted to create the "/home/facebook/people" and "/home/facebook/tech" directories from scratch, you would need four commands: mkdir /home mkdir /home/facebook mkdir /home/facebook/people mkdir /home/facebook/tech Given the full set of directories already existing on your computer, and a set of new directories you want to create if they do not already exist, how many mkdir commands do you need to use? Input The first line of the input gives the number of test cases, T.T test cases follow. Each case begins with a line containing two integers N and M, separated by a space. The next N lines each give the path of one directory that already exists on your computer.This list will include every directory already on your computer other than the root directory.(The root directory is on every computer, so there is no need to list it explicitly.) The next M lines each give the path of one directory that you want to create. Each of the paths in the input is formatted as in the problem statement above. Specifically, a path consists of one or more lower-case alpha-numeric strings(i.e., strings containing only the symbols 'a'-'z' and '0'-'9'), each preceded by a single forward slash. These alpha-numeric strings are never empty. Output For each test case, output one line containing "Case #x: y", where x is the case number(starting from 1) and y is the number of mkdir you need. Note: If a directory is listed as being on your computer, then its parent directory will also be listed,

unless the parent is the root directory. INPUT 2 12 /chicken /chicken/egg /chicken 13 /a /a/b /a/c /b/b OUTPUT Case #1: 1 Case #2: 4 (29) A magic wish-granting rectangular belt always shrinks to 1/2 its length and 1/3 its width whenever its owner makes a wish. After three wishes, the surface area of the belt's front side was 4 cm2. What was the original length, if the original width was 9 cm? (30) Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new values are generated. (31) Design a data structure to represent the movement of a knight on a chess board. (32) Two sorted arrays A and B have been given.such that size of A is m and size of B is n. You need to find the k th largest sum (a+b) where a is taken from A and b is taken from B. such that k < m*n. (33) Input a number C , an output all of the ways that a group of ascending positive numbers can be summed to give C. for e.g if C=6,the output should be 1+2+3 1+5 2+4 (34) For a set S of n real numbers, a pair of elements x, y belong to S,where x < y, are said to be close if y x <= ( max(S) min(S) ) / (n-1).Suppose you are given an unsorted array A[1 : n] of distinct real numbers. Design an algorithm that finds a pair of close numbers in A in O(n) time. (35) you are given an array A of k values which contain int values in sorted (asec) order. Find top k values (asec) which can either be the number from the array A, or sum of any two numbers from A or sum of any three numbers from A. So, if A's values are represented as : a1,a2,...,ak , the possible numbers can be: a(i), a(i)+a(j), a(i)+a(j)+a(l) for any i,j,l < k

Ex: A[7] = {3,4,5,15,19,20,25} output B[7] = {3,4,5,(3+4),(3+5),(4+5),(3+4+5)} (36) Given an n-ary tree of resources arranged hierarchically. A process needs to lock a resource node in order to use it. But a node cannot be locked if any of its descendant or ancestor is locked. You are supposed to: -write the structure of node -write codes for * Islock()- returns true if a given node is locked and false if it is not * Lock()- locks the given node if possible and updates lock information * Unlock()- unlocks the node and updates information. -Codes should be : * Islock O(1) * Lock()- O(log n) * unLock()- O(log n) (37) one system API available setOStimer(time n, function ptr, function arg) it sets time for n sec. after expiration of timer it calls function. if another timer set with setOStimer, it will erase previously sets timer. Ex. at t = 0, setOStimer(5,fn,arg) at t = 4, setOStimer(10,fn1,arg1) now first timer removed. Question is using this API, write own API setTimer(), it will use given API. So that it will not erase previously set timer. (38) Write a method that takes an int array of size m, and returns (True/False) if the array consists of the numbers n...n+m-1, all numbers in that range and only numbers in that range. The array is not guaranteed to be sorted. (For instance, {2,3,4} would return true. {1,3,1} would return false, {1,2,4} would return false. The problem I had with this one is that my interviewer kept asking me to optimize (faster O(n), less memory, etc), to the point where he claimed you could do it in one pass of the array using a constant amount of memory. Never figured that one out. (39) Given a string. For example input string is sandeep. Given Permutation is : psdenae. find the position of the given permuation in the sorted list of the permutations of the original string. (40) Given a Circularly doubly linked list... How can i convert it into Binary Search Tree.. (41) Convert a maximum heap to a binarGiven an array A[i..j] find out maximum j-i such that A[i]<a[j] in O(n) timey search tree. (42) You're an electrician working at a mountain. There are N wires running from one side of the mountain to the other. The problem is that the wires are not labeled, so you just see N wire ends on each side of the mountain. Your job is to match these ends (say, by labeling the two ends of each wire in the same way). In order to figure out the matching, you can twist together wire ends, thus electrically connecting the wires. You can twist as many wire ends as you want, into as many clusters as you want, at the side of the mountain where you happen to be at the time. You can also untwist the wire ends at the side of the mountain where you're at. You are equipped with an Ohm

meter, which lets you test the connectivity of any pair of wires. (Actually, it's an abstract Ohm meter, in that it only tells you whether or not two things are connected, not the exact resistance.) You are not charged [no pun intended] for twisting, untwisting, and using the Ohm meter. You are only charged for each helicopter ride you make from one side of the mountain to the other. What is the best way to match the wires? (Oh, N>2, for there is no solution when N=2.) (43) We are given a checkerboard which has 4 rows and n columns, and has an integer written in each square. We are also given a set of 2n pebbles, and we want to place some or all of these on the checkerboard (each pebble can be placed on exactly one square) so as to maximize the sum of the integers in the squares that are covered by pebbles. There is one constraint: for a placement of pebbles to be legal, no two of them can be on horizontally or vertically adjacent squares (diagonal adjacency is fine). (a) Determine the number of legal patterns that can occur in any column (in isolation, ignoring the pebbles in adjacent columns) anddescribe these patterns (44) You are given N line segments numbered 1 to N. The lengths of these segments are given in the int[] segments. Compose a convex K-sided polygon, where each side is one of the given segments. Each segment can only be used once in the polygon. Return the number of different polygons you can compose. Two polygons are considered different if there exists a segment i such that one of the polygons contains segment i but the other polygon does not. (45) An array A[1 n] contains all the integers from 0 to n except for one number which is missing . In this problem, we cannot access an entire integer in A with a single operation . The elements of A are represented in binary, and the only operation we can use to access them is fetch the jth bit of A[i], which takes constant time Write code to find the missing integer . Can you do it in O(n) time? (46) Given an integer, print the next smallest and next largest number that have the same number of 1 bits in their binary representation . (47) There is a row of houses in which each house contains some amount of money. Write an algorithm that loots the maximum amount of money from these houses. The only restriction is that you cannot loot two houses that are directly next to each other. (48) Divide a list of numbers into groups of consecutive numbers but their original order should be preserved. Example: <8,2,4,7,1,0,3,6> Two groups: <2,4,1,0,3><8,7,6> Better than O(n^2) is expected. (49) You are given two height balanced binary search trees T and T, storing m and n elements respectively. Every element of tree T is smaller than every element of tree T. Every node u also stores height of the subtree rooted at it. Using this extra information how can you merge the two trees in time O(log m + log n) (preserving both the height balance and the order)?

(50) Given a distribution of packages on media and a list of dependences between packages, you have to calculate the minimal number of media changes required to install all packages. For your convenience, you may assume that the operating system comes on exactly 2 DVDs. (51) Given n points on a 2D coordinate system . What is the most efficient way of finding nearest point for each point? How can we find all the points at a distance k from a given point efficiently? (52) Suppose you want to travel from city A to city B by car, following a fixed route. Your car can travel m miles on a full tank of gas, and you have a map of the n gas stations on the route between A and B that gives the number of miles between each station. Design an algorithm to find a way to get from A to B without running out of gas that minimizes the total number of refueling stops, in O(n) time. (53) given a string find the number of distinct substrings of the string. ex: input-aaaa output-4(a, aa, aaa, aaaa) input-abcd output-10(a, b, c, d, ab, bc, cd, abc, bcd, abcd) (54) Given an unsorted array A of n distinct numbers and an integer k where 1 <= k <= n, design an algorithm that finds the k numbers in A that are closest in value to the median of A in O(n) time (55) In this variation of the Maximum-Sum Subarray Problem, you are given a one-dimensional array A[1 : n] of positive or negative numbers, and you are asked to find a subarray A[i : j] such that the sum of its elements is (1) strictly greater than zero, and (2) minimum. In other words, you want to find a subarray of smallest positive sum. Give an O(nlog^2n) Divide and Conquer algorithm and a O(nlogn) Dynamic Programming Algorithm. (56) You are given a wooden log of length n. It has n+1 grooves marked on it from 0 to n. You are given an array containing numbers within the range of 1 to n-1. These elements of the array represents the points on the log at which u need to cut the wooden log. Now the cost of cutting a log is proportional to the length of the original log being cut. Eg: n=15 and A={1,5,9} Now when u make a cut at 1, the cost is n (the size of original log) When u cut at 9, the cost will be n-1 as the length of the new original log is 1 to n i.e n-1 When u cut at 5, since 5 lies between 1 and 9 and the length of this log is 9-1=8, so the cost will be 8. The question is: given the value of 'n' and the Array A containing the points at which u need to make a cut, find the order in which the cuts must be made in order to minimize the total cost of cutting the wooden log. (57) Calculate size of a data type without using sizeof and without declaring any variable of it....

(58) "Build a data structure on array B[1..n] in O(n) time such that the following problem can be solved in O(log n) time: Given an index i and value v, find the index j of the first element in B such that j >= i and B[j]>v. Return -1 if no such j exists. (59) we have to print all combination of all number in given range that can compose a given number Examples: For n = 1, the program should print following: 1 For n = 2, the program should print following: 11 2 For n = 3, the program should print following: 111 12 21 (60) Given an integer set C={c_1, c_2, ... c_n} where c_1=1 and c_i < c_{i+1}, and an positive integer M, find the minimum of sum_{i=1}^n x_i, where all x_i's are non-negative integers and subject to sum_{i=1}^n x_i c_i = M (61) given file containing roughly 300 million social security nos.( 9 digit nos.) find a 9 digit no. that is not in the file. you have unlimited drive space but only 2 megabytes of RAM at your disposal (62) Suppose n people are arranged in a circle. Number the people from 1 to n. in the clockwise order. We are given an integer ,m <= n. Beginning with the person with designated number 1, we proceed around the circle (in clockwise order) removing every mth person. After each person is removed, counting continues around the circle that remains. This process continues until all the n people have been removed. . The .m-permutation is defined as the order in which the people have been removed. As an example, if n = 7, m = 3, then the 3 permutation is 3,6,2,7,5,1,4. Give an O(n log n) time algorithm which given m and n outputs the mpermutation. (63) Given: An array of integers(may be both positive and negative), we have to find out the minimum positive sum of array(not necessarily continuous). example:- {1,-5,7,10,-14,16,-17,20,21,22} here answer is -5,-17,22 having sum=0; (64) sort the input array. only following operations on array is allowed: 1)get(index) -gets the element at that index 2)reverse(int start,int end) - example reverse(1,3) for the array [1,2,3,4,5] will return [1,4,3,2,5] (65) many irregular shape objects are moving in random direction. provide data structure and algo to

detect collision. Remember that objects are in million (66) Given a string (assume there no spaces or punctuations), write a program that returns the max. length of the string that has repeated more than once (67) Design an algorithm to find the majority element of an array majority element must be an element tht has the cardinality greater than 2n/3 where n is the number of elements in the array and the time complexity must be a linear time.. ie o(n).. (68) Write an algorithm to compute the next multiple of 8 for a given positive integer using bitwise operators. Example, (a) For the number 12, the next multiple of 8 is 16. (b) For the number 16, the next multiple of 8 is 24. (69) Given a 2d array which is sorted row wise and column wise as well, find a specific element in it in LESS THAN O(n). (70) finding largest and second largest elements from a set of n elements (71) For the data flow graph G= (V,E),I have to determine a partition in such a way that sub graphs created could be computed in parallel and the sub graphs are approximately of the same size (sqrt(| V|)) For example as in graph attached ( http://i55.tinypic.com/35lvu6x.png the graph should be directed upwards) - B0,B1,B2 - describe partially the partition. (72) Design a hash table to store phone #s. Your job is to write a hash function that has a parameter username, and generate a key. Username is unique, length 5 and can be A-Z, 0-9, space. Write a hash function that generate keys without collisions and use minimum memory. (73) Find the number of ways for generating n pairs of valid parenthesis. A set of parenthesis is said to be valid if at any instant while scanning from left to right, the number of opening parenthesis are never less than the number of closing parenthesis. For ex: for n=3, f(n) = 5 ()()(), ((())), (()()), ()(()), (())() (74) In a linked list how to insert an element at 3rd position given a pointer to 4th position (75) Find kth largest of sum of elements in 2 sorted array. (76) If one linked list contain characters o x e n c and second contain characters e n c a r t a then the

final linked list should contain o x e n c a r t a i.e. if the end of one list is same as the start of second then those characters should come only once. can we do it in O(n+m) where n and m are the length of list. both are singly link list. (77) Given two binary trees T1 and T2 which store character data, duplicates allowed. You have to devise an algorithm to decide whether the T2 is a subtree of T1. T1 has millions of nodes and T2 has hundreds of nodes. (78) Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations (79) There is a binary tree(Not a BST) in which you are given three nodes x,y,z .Write a function which finds whether y lies in the path b/w x and z. (80) you will be given an input no. n u have to output nth twin pair for eg input 1 output(3,5) input 5 output (29,31) twin pair is a pair in which prime no. differ by 2.. (3,5) , (5,7) , (11,13), (17,19) (29,31) (81) how to find kth largest in bst. u cnt use static/global variable and u cnt pass value of k to any function. (82) Sort string based upon the count of characters Smaple Data : input : "abcdacdc" Output : "cadb" If the count is same for characters. maintain the original order of the characters from input string. (83) I have a symmetric matrix. I am wondering what would be the best data structure to store such a matrix? How many elements do I need to store for a nxn matrix? (84) You have N computers and [Ca, Cb] means a is connected to b and this connectivity is symmetric and transitive. then write a program which checks this (85) Given an array of integers of size 'n' - consisting of 'n-2' unique integers and 1 integer with a duplicate, find the repeated element in O(n). (86) how to find if two arrays of size n are disjoint or not in O(n) time ?? You can use only O(n) space............ (87) An ideal string is a string where the 1-based index of the first occurrence of each letter is equal to the number of occurrences of

that letter in the string. For example, the BAOOOA is an ideal string (quotes for clarity only). The letter B appears 1 time, and its index is 1. The letter A occurs 2 times and its first index is 2. The letter O occurs 3 times and its first index is 3. Given an int length, return the lexicographical smallest ideal string of that length containing only uppercase letters (A-'Z). If there are no such ideal strings of that length, return an empty String instead. (88) A sequence of numbers is called a zig-zag sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a zig-zag sequence. For example, 1,7,4,9,2,5 is a zig-zag sequence because the differences (6,-3,5,7,3) are alternately positive and negative. In contrast, 1,4,7,2,5 and 1,7,4,5,5 are not zig-zag sequences, the first because its first two differences are positive and the second because its last difference is zero. Given a sequence of integers, sequence, return the length of the longest subsequence of sequence that is a zig-zag sequence. A subsequence is obtained by deleting some number of elements (possibly zero) from the original sequence, leaving the remaining elements in their original order. (89) Given an integer array of which both first half and second half are sorted. Write a function to merge the two parts to create one single sorted array in place [do not use any extra space]. e.g. If input array is [1,3,6,8,-5,-2,3,8] It should be converted to: [-5,-2,1,3,3,6,8,8] (90) Convert BT in to DLL such that DLL represents the Sprial order traversal of BT. "Inplace" (91) You are given an array (unsorted) and for every element i, find the first occurance of an element j (in the remaining array) that is greater than or equal to i. If no such j occurs then print -1. Eg: Input---> A={1,3,5,7,6,4,8} Output---> 3 5 7 8 8 8 -1 Time Complexity:O(n) Space Complexity:O(n) (92) Given a series A,B,C .......Z, AA, AB,AC,AD....AZ,BA,BB...BZ,CA.... (Open excel sheet. The names of column represent the series). Given input as number 'n'. Output the 'n' th string of the series. & also vice versa if given string prints its corresponding string...e.g given AC then its integer is 29 & given 40774 its string value is ABZ.. (93) "A blind man is given deck of 52 cards with 10 card facing up and rest are facing down. He need to create two piles not necessarily of same height in order to have same number of up cards in both." (94) Write a function to check whether the Binary Tree is mirror structure.

True (A (B (C,D), E( F,G))) or (A (B (C)), D(E))) False (A (B)) or (A (B,C(D,E))) tree is represented in string form as given above (95) Write a function to print all unique partitions on n tht are of size m. eg: n=10, m=4. it should print 7 1 1 1, 6 2 1 1, 5 3 1 1, 3 3 2 2,, so on (96) you are given a bst where each node has a int value , parent pointer , and left and right pointers , write a function to find a path with a given sum value. Path can go from left subtree tree , include root and go to right tree as well . we need to find these paths also . 5 / \ 1 10 /\ /\ 0 2 6 11 so to find 16 we say it is 1 to 5 to 10 &10 to 6 try make use of parent pointer and find a solution :-o (97) There is a firm that provides Mobile Operator 3 functions. char[] get_number: to get a new number(10 digit) bool is_allocated(char[]) : if the number is already allocated. bool allocate(char[]) : allocate the number. What data structure to use? We can use hash table to store the number that is already allocated. char[] get_number() { Generate the random 10 digit number. } bool is_allocated(char[] num) { Get the lock Hash the given number. Index the hash to the hash table. Look for collision. if collide return true else return false. release the lock } bool allocate(char[] num) { Get the lock hash the given number Index the hash to the hash table set the entry in the hash table for the given index.

release the lock } (98) You are given a array with rows sorted and column sorted. You have to print entire array in sorted order. (99) Numbers are randomly generated and passed to a method. Write a program to find and maintain the median value as new values are generated (100) A non-negative integer is called heavy if the average value of its digits in decimal representation exceeds 7. Assume that 0 has average value of its digits equal to 0. For example the number 8698 is heavy, because the average value of its digits equal to (8+6+9+8)/4 = 7.75. The number 53141 has the average value of its digits equal to (5+3+1+4+1)/5 = 2.6, so it is not heavy. Write a function int heavy_decimal_count(int a,int b); that given two non-negative integers A and B returns the number of heavy integers in the interval [A..B] (both ends included). Assume that 0 <=A <= B <= 200,000,000 Range Given ..It Really Matters Your Program should not give time out & memory error For example, given A=8,675 and B=8,689 the function should return 5, because there are 5 heavy integers in range [8,675..8,689]: 8675 avg=6.5 8676 avg=6.75 8677 avg=7 8678 avg=7.25 HEAVY 8679 avg=7.5 HEAVY 8680 avg=5.5 8681 avg=5.75 8682 avg=6 8683 avg=6.25 8684 avg=6.5 8685 avg=6.75 8686 avg=7 8687 avg=7.25 HEAVY 8688 avg=7.5 HEAVY 8689 avg=7.75 HEAVY you have to keep in mind for given range e.g given B<=2 Billion Its Man Thing so what happen when A=1 Billion & B=2 Billion (101) For a set S of n real numbers, a pair of elements x, y belong to S, where x < y, are said to be close if y x <= ( max(S) min(S) ) / (n-1) Suppose you are given an unsorted array A[1 : n] of distinct real numbers. Design an algorithm that finds a pair of close numbers in A in O(n) time. (102) You have to paint N boards of length {B1, B2, B3 BN}. There are K painters available and you are also given how much time a painter takes to paint 1 unit of board. You have to get this job done as soon as possible under the constraints that any painter will only paint continuous sections of board, say board {2, 3, 4} or only board {1} or nothing but not board {2, 4, 5}. (103)

Given n elements, sort the elements. Here, only one operation is permitted decreaseValue.. Note that you cannot swap the values.. output should be a sorted list.. if input is 4 5 2 1 3 output is 3 3 3.. There can be many answers.. Give the optimum solution with minimum cost. where as cost is the sum of decreased amounts (104) There are k systems given and each system has n numbers in the sorted order. You are given a new system which has a space of O(k). Your system can contact with any other system and fetch a number from it. Your task is to write all these n*k numbers into a file in the sorted order using the system that was given to you. (105) Given an array A[i..j] find out maximum j-i such that A[i]<A[j] in O(n) time (106) Design an algorithm to find whether a given string is formed by the interleaving of two given strings or not. e.g. s1= aabccabc s2= dbbabc s3=aabdbbccababcc Given s1,s2,s3 design an efficient algorithm to find whether s3 is formed from the interleaving of s1 and s2. (107) Sort all elements in odd indices of an array in ascending order and even indices in descending order. Finally, rearrange so that all even indexed elements come first. eg: input 7 2 6 4 8 3 1 even indexed : 7 6 8 1 => sort 8 7 6 1 odd indexed: 2 4 3 => sort 2 3 4 output 8 7 6 1 2 3 4 What could be the best algo to solve it? Is it possible to arrive at the output using only O(1) extra space? (108) Given an array of elements find the largest possible number that can be formed by using the elements of the array. eg: 10 9 eg: 2 3 5 78 eg: 100 9 ans: 910 ans: 78532 ans: 9100 (109) Given 2 sorted arrays: A and B each holding n and m elements respectively,. Hence, total no. of elements = m+n Give an algorithm to place the smallest 'm' elements(out of the m+n total available) in A and the largest 'n' elements in B. ( A and B need not be sorted in the end) eg: A : 1 2 3 B: 0 1.5 4 5 9 Output: A can contain any combination of nos 0,1,1.5 and B should contain 2 3 4 5 9 (in any order.) Constraints: No extra space. Linear Time preferred (110) There are n persons. You are provided with a list of ppl which each person does not like. Determine the minm no. of houses required such that, in no house 2 people should dislike each other. Is there a polynomial time solution exist for this? Or is this not solvable at all?

(111) Given a binary tree(not a BST) find the 2 nodes of the binary tree which are separated by maximum distance. By distance, we mean no. of edges in the path from node1 to node2. (112) A long array A[] is given to you. There is a sliding window of size w, which is moving from the very left of the array to the very right. You can only see the w numbers in the window. Each time the sliding window moves rightwards by one position. (113) Given a huge circular area containing lot of people (whose positions are given as coordinates) how will you place dustbins in the area, such that no person has to move more than 100 metres to reach a dustbin. Minimize the number of dustbins. (114) You are given the downloads folder on a computer which may contain a number of files that are duplicates of each other. (these files are the same byte-wise but may have diff names) describe a method which identifies all duplicates in the least amount of time. (115) Now there are k computers each with 1000000 files. You need to determine efficiently the duplicates across all these computers. State the assumptions in terms of topology, connecting device etc. (116) Given a set of non-overlapping integer ranges (1,3) (5,8), etc., and an input integer, what is the best way to organize the data and allow for quick search based on the input, etc. (117) Print a singly-linked list backwards, in constant space and linear time. (118) Convert a binary search tree to a sorted, circular, doubly-linked list, in place (using the tree nodes as the new list nodes). (119) Write a function to tell if two line segments intersect or not. (120) You are given intervals of contiguous integers, like [1, 10), [15, 25), [40, 50), which are nonoverlapping and of a fixed size. Design a data structure to store these intervals and have the operations of insert, delete, and find functions (121) Given sorted arrays of length n and 2n with n elements each, merge first array into second array. (122) Write a function that computes log2() using sqrt() (123)

Stack A has the entries a,b,c ( with a on the TOp) Stack B is empty. An entry pooped out of the stack A can be printed immediatly or pushed to stack B. An Entry popped out of the stack B can only be printed. In this Arrangement ,if Stack A has 4 entries, then number of possible permutation will be (a) 24 (b) 12 (c) 21 (d) 14 for 3 entries ..solution is 5.....abc,cba,bac,bca,acb....(except cab)..its like 3! - 1 (n! - 1 for n=3) Is there any easy way to find for 4 entries ???...also what is the general solution ?? (124) Given a two balanced binary search trees.Merge both the trees so that it will form again a balanced binary search tree.

- The wonderful world of TregexDiunggah olehSR
- C++ practice questions.pdfDiunggah olehashushaktiman
- WKP115S ActivitiesDiunggah olehlizhuerta
- SmartSketch CodeDiunggah olehsimran
- In-memory URL CompressionDiunggah oleh.xml
- Rock MechanicsDiunggah olehpersianknight
- 4.Decision TablesDiunggah olehJohn808
- 07a1ec04 Computer ProgrammingDiunggah olehandhracolleges
- Meljun Cortes Data Structures Types of Binary Search TreeDiunggah olehMELJUN CORTES, MBA,MPA
- DS Unit 2Diunggah olehSubathra Devi Mourougane
- 2008 Base PaperDiunggah oleh786sheik786
- Persistent 11Diunggah olehtejasn1000
- c programmingDiunggah olehSohel Ahmed
- Tree based Techniques for web access patterns – a surveyDiunggah olehAnonymous vQrJlEN
- Introduction to AlgorithmsDiunggah olehXeeshan Ali
- AmeDiunggah olehSuhas Reddy Podduturi
- MIT6_851S12_ps1sDiunggah olehdjoseph_1
- Priority queues on parallel machinesDiunggah olehfonseca_r
- slides12-continuations.pdfDiunggah oleh252966576
- A DATA MINING APPROACH TO PREDICT PROSPECTIVE BUSINESS SECTORS FOR LENDING IN RETAIL BANKING USING DECISION TREEDiunggah olehLewis Torres
- ADS Cheat SheetDiunggah olehbssandeshbs
- Arboles_2-3-4Diunggah olehKevin Salazar
- Binary TreeDiunggah olehDHRUV CHAUHAN
- Species Delimitation Plugin ManualDiunggah olehRicardo García
- MC7104-Data Structures and AlgorithmsDiunggah olehklaus18
- blow upDiunggah olehnavneetgupta13
- Datastructure and Algorithms McqDiunggah olehShivam
- Introduction to ComputingDiunggah olehNada
- 24Trees02Diunggah olehankurkothari
- Seminar Ppt 1Diunggah olehPARAMVIR SINGH

- Difficulties_encountered_by_students_in.docxDiunggah olehHenry Micheal
- Hand Eye CalibrationDiunggah oleh허성욱
- indexlawsrevisionDiunggah olehapi-241951122
- Tan et al 2006Diunggah olehAparupa Dasgupta
- There Are Changes to the Structure of Some CSEC and CAPE Examinations PapersDiunggah olehkemi gittens
- Continuous+Time+Signals Unit1Diunggah olehGaurav Tiwari
- Euler and HamiltonDiunggah olehAlya Nadhirah Abdul Wahid
- chapter 3 - scientific measurement pptDiunggah olehapi-239855791
- Book MatlabDiunggah olehTomy Angga Kusuma
- GenMath Initial ReleaseDiunggah olehGwen Soriano
- Dynamic ProgrammingDiunggah olehQUrnia Wulan Cucur
- Midterm PrecalDiunggah olehjohn christian de leon
- A Solution of Following Differential Equation is Given ByDiunggah olehKaran Rathore
- Programming with C++_Lecture4.pptxDiunggah olehAbdul baseer
- Burkhard Heim Mass FormulaDiunggah olehkoispam
- EXCEL Referance - Jan ZumwaltDiunggah olehjwzumwalt
- Kumon Math LevelsDiunggah olehMarcelo Pinheiro
- Even Num 0 & Odd Num 1Diunggah olehPrem Nagarajan
- Averages Level 2Diunggah olehVeeraragavan Subramaniam
- Counting IDiunggah olehrubina.sk
- TOURNIKIOTIS on architectural space in greece.pdfDiunggah olehexe
- Adaptation in Dynamical Systems.pdfDiunggah olehrambo_style19
- Differential and Int Clyde.Diunggah olehsadna fernando
- CBSE Class 11 Maths Notes _ Circles.pdfDiunggah olehBhawani Singh Balot
- IFEM.Ch11Diunggah olehArun Santhosh Samfisher
- Tournament of Towns 2010Diunggah olehOkla
- Syllabus in Math AlgebraDiunggah olehkimchen edenelle
- Math igcse paperDiunggah olehjainishpatel17
- Andrew Liddle General RelativityDiunggah olehAyan Mitra
- Student Lecture 43 Fourier Series (2)Diunggah olehuploadingperson

## Lebih dari sekadar dokumen.