CEG's Linux User Group

  • Increase font size
  • Default font size
  • Decrease font size
Home Labs
Labs

Intersection of Two lists

E-mail Print
User Rating: / 4
PoorBest 
INTERSECTION OF TWO LISTS


INTRODUCTION:

The objective of the 'Intersection of two list' is to find the common elements in two lists taken into consideration.  It is to be noted that this code works fine for only SORTED LISTS.  Incase if unsorted lists are taken into consideration,  we need to call the sort() function inorder to sort the lists and then find the common elements in the lists.

In the source code, 'temp1' and 'temp2' are pointers that are used to traverse the list  L1 and L2 respectively.  These two temporary variables point to the first element of the lists initially.

Initially first element of the List L1 is compared with the first element of the  List L2.  If the former is smaller, only List L1  is traversed , or if the latter is smaller , only List L2 is traversed.  If there is any element in common, then that element is inserted into another new list called 'm' and in this case both the lists are traversed together .  It is to be noted that in any of the above cases , the lists can be traversed using 'while' loop only if temp1 and temp2 don't point to NULL.

Last Updated on Tuesday, 09 June 2009 20:49 Read more...
 

Reversing a binary search tree using stack

E-mail Print
User Rating: / 3
PoorBest 

REVERSING A BINARY SEARCH TREE USING STACK


Introduction:

In computer science, a binary search tree (BST) is a binary tree data structure

The major advantage of binary search trees over other data structures is that the related sorting algorithms and search algorithms such as in-order traversal can be very efficient.

One such application of the binary search tree is that it can be used for arranging a given string in sorted alphabetical order. In this characters are arranged as per the structure property of binary tree using the ASCII value of the characters in the string. In this program the characters are obtained from the user and it is inserted into the binary search tree. after this the tree is reversed using a stack by pushing the elements and then popping them from the stack.

Last Updated on Saturday, 13 June 2009 18:02 Read more...
 

Union of Lists

E-mail Print
User Rating: / 5
PoorBest 

UNION OF LISTS

Introduction :

The objective of this program is to find the union of two lists. The union of the lists includes all the elements of both the lists, but the elements common to the lists are inserted only once. Consider two lists of 2 nodes each. Let l1 and l2 pointers point to the first nodes of list1 and list2 respectively. Let m be the list containing the union of lists. The lists l1 and l2 are displayed below.

Last Updated on Tuesday, 09 June 2009 20:52 Read more...
 

IMPLEMENTATION OF STACK USING ADT

E-mail Print
User Rating: / 7
PoorBest 

STACKS

 

A stack is an ordered collection of elements in which insertions and deletions are restricted to one end. The end from which elements are added or removed is referred as the top of the stack.Stacks are also referred as pilesor push down lists.The first element placed in the stack will be at the bottom of the stack. The last element placed in the stack will be at the top of the stack. The last element added to stack is the first element to be removed. Hence stacks are referred as Last In First Out(LIFO)lists or First In Last Out(FILO) lists.

Last Updated on Tuesday, 09 June 2009 23:32 Read more...
 

Doubly Linked List

E-mail Print
User Rating: / 8
PoorBest 

DOUBLY LINKED LIST

 

A linked list is a linear data structure used to organize the data in the memory. As the name indicates, linked list is a list of items called the 'NODE' linked using pointers. A  'NODE' is a structure of List containing two or more fields called the 'data' field and 'address' field.

DOUBLY LINKED LIST:

The following figure shows a doubly linked list . The link is two way. Here every NODE contains two pointers LPTR(left pointer) and the RPTR (right pointer).

  • LPTR  points to the previous node.
  • RPTR points to the next node.


The advantage of a doubly linked list  is that  traversal becomes easy.

 

Last Updated on Tuesday, 09 June 2009 13:01 Read more...
 

Reversing a List

E-mail Print
User Rating: / 2
PoorBest 

REVERSING A LIST


INTRODUCTION:

The objective of 'Reversing a List' program is to place the elements in the list in the reverse order.

For instance, consider a list having three nodes...

Last Updated on Tuesday, 09 June 2009 12:50 Read more...
 

Binary Search Tree

E-mail Print
User Rating: / 7
PoorBest 

Binary search tree

In computer science, a binary search tree (BST) is a binary tree data structure which has the following properties:

 

  • § Each node (item in the tree) has a distinct value.
  • § Both the left and right subtrees must also be binary search trees.
  • § The left subtree of a node contains only values less than the node's value.
  • § The right subtree of a node contains only values greater than the node's value.

 

The major advantage of binary search trees over other data structures is that the related sorting algorithms and search algorithms such as in-order traversal can be very efficient.

Binary search trees can choose to allow or disallow duplicate values, depending on the implementation.

Binary search trees are a fundamental data structure used to construct more abstract data structures such as sets, multisets, and associative arrays.

Last Updated on Monday, 08 June 2009 16:57 Read more...
 


Page 2 of 4