Posts

Showing posts from July, 2020

Important concepts and problem

=>  Maximum Consecutive Gap => Solution , Hindi => Longest Common Subsequece (LCM) => Solution Simple implementation of LCM to find largest palindromic sunsequence => Distinct subsequence => Solution => Dynamic Problems => Solution  -----------xxxxx------ END-----xxxxx

Link List

Image
A linked list is a data structure in which the objects are arranged in a linear order. Unlike an array, however, in which the linear order is determined by the array indices, the order in a linked list is determined by a pointer in each object. Linked lists provide a simple, flexible representation for dynamic sets, supporting (though not necessarily efficiently) all the operations. As shown in Figure 10.3, each element of a doubly linked list L is an object with an attribute key and two other pointer attributes: next and pre . The object may also contain other satellite data. Given an element x in the list, x.next points to its successor in the linked list, and x.pre points to its predecessor. If x.pre  = NIL, the element x has no predecessor and is therefore the first element, or head, of the list. If x.next  = NIL, the element x has no successor and is therefore the last element, or tail, of the list. An attribute L.head points to the first element of the list. If...

Introduction to sorting

Introduction Any number of practical applications in computing require things to be in order. Even before we start computing, the importance of sorting is drilled into us. From group pictures that require the tallest people to stand in the back, to the highest grossing salesman getting the largest Christmas bonus, the need to put things smallest to largest or first to last cannot be underestimated. When we query a database, and append an ORDER BY clause, we are sorting. When we look for an entry in the phone book, we are dealing with a list that has already been sorted. (And imagine if it weren’t!) If you need to search through an array efficiently using a binary search, it is necessary to first sort the array. When a problem statement dictates that in the case of a tie we should return the lexicographically first result, well… you get the idea. General Considerations Imagine taking a group of people, giving them each a deck of cards that has been shuffled, and requesting that they sor...