Kamal Rawat's Blog, page 4

October 12, 2018

String Matching Algorithms

Given a string of characters, search for a pattern (another smaller string) in the string. For example, if given string is Ritambhara Technologies for Coding Interviews and the pattern is Tech, then the pattern is present in the string. If the pattern that we are looking for is Moksha, then this pattern is not present […]
 •  0 comments  •  flag
Share on Twitter
Published on October 12, 2018 19:57

September 4, 2018

Add numbers given in the form of Linked List

Two numbers are given in the form of linked list (with each node storing one digit). Write an algorithm which will compute the sum of these two linked lists. The result should be a linked list as below: Solution: If you don’t want to read, you can watch the video below: The problem is because […]
 •  0 comments  •  flag
Share on Twitter
Published on September 04, 2018 12:59

Find Merge-Point of two Linked Lists

Given two linked lists that merge at some point as shown below: Last four nodes are common to both the lists. Given pointers to the header nodes of each list, find the first common node. Note: If you do not want to read the solution, you can watch the video: Solution-1: Brute Force The brute-force solution […]
 •  0 comments  •  flag
Share on Twitter
Published on September 04, 2018 01:01

July 21, 2018

Find two elements in an array whose sum is x

Given an array of integers and a number x. check if there exists two elements in the array whose sum = x. For every element arr[i] of the array, we need to check if the array contains (x-arr[i]) in it or not. This search for (x-arr[i]) can be made using linear search (O(n) -time algorithm), […]
 •  0 comments  •  flag
Share on Twitter
Published on July 21, 2018 13:24

July 18, 2018

DATABASE FOR PLACEMENT PREPARATION. PART_2

This is the first videos in a series of videos meant for B.Tech students who want to prepare database for placement (either campus placement or off-campus). If you want to brush up your database concepts, you may like the video. B.Tech students from other streams (Electrical, Mech., Civil, etc.) who want to sit in the […]
 •  0 comments  •  flag
Share on Twitter
Published on July 18, 2018 04:39

July 17, 2018

Database for placement preparation. Part_1

This is the first videos in a series of videos meant for B.Tech students who want to prepare database for placement (either campus placement or off-campus). If you want to brush up your database concepts, you may like the video. B.Tech students from other streams (Electrical, Mech., Civil, etc.) who want to sit in the […]
 •  0 comments  •  flag
Share on Twitter
Published on July 17, 2018 21:18

June 15, 2018

Implementing Genric queue data structure in Java

Given the linked list implementation of a generic queue in Java. We have already seen linked list implementation of Queue data structure in C++ earlier. In this post, we are going to give a similar implementation in Java. Also, we want to keep our implementation generic so that we can store any type of data in […]
 •  0 comments  •  flag
Share on Twitter
Published on June 15, 2018 02:43

June 11, 2018

Search in a sorted multi-level linked list

Given a multi-level linked list as shown in this post. Write code to search in such a list. The structure of the list is as shown below: The important thing is that each of the child lists is sorted and all the elements in the child list of a node are less than the next […]
 •  0 comments  •  flag
Share on Twitter
Published on June 11, 2018 04:31

Printed a sorted multi-level linked list

Given a linked list, where each node has a pointer to the head of its child list (in addition to the next pointer). The child list is a normal linked list with each node having one data and one pointer to the next node in the child list. Let the lists be arranged (as above) […]
 •  0 comments  •  flag
Share on Twitter
Published on June 11, 2018 03:17

Traverse and print a linked list in forward and backward order

Given a linked list, write code to print the list in forward and backward order. Solution: This problem is discussed as an example in this post. A linked list is a data structure where address of next node is stored inside each node. Structure of Node Structure of Node of a list is as given […]
 •  0 comments  •  flag
Share on Twitter
Published on June 11, 2018 03:04