# Data Structure Tutorial

## Introduction to Data structures

Introduction to Data structures Software engineering is the study of ways in which to create large and complex computer applications and that generally involve many programmers and designers. At the heart of software engineering is with the overall design of the applications and on the creation of a design that is based on the needs …

## Introduction to Pointer

Introduction to Pointer To understand pointers, you need a basic knowledge of how your computer stores infor-mation in memory. The following is a somewhat simplified account of PC memory storage. Pointers are so commonly used as references that sometimes people use the word “pointer” to refer to references in general; however, more properly it only …

## Declaration & Syntax In Pointer

Pointers are declared by using the * in front of the variable identifier. For example: int *ip; float *fp = NULL; This declares a pointer, ip, to an integer. Let’s say we want ip to point to an integer. The second line declares a pointer to a float, but initializes the pointer to point to …

## Working with Pointers

Imagine that we have an int called i. Its address could be represented by the symbol &i. If the pointer is to be stored as a variable, it should be stored like this. int *pi = &i; int * is the notation for a pointer to an int. & is the operator which returns the …

## Introduction to Arrays

Introduction to Arrays An array is a data structure used to process multiple elements with the same data type when a number of such elements are known. You would use an array when, for example, you want to find out the average grades of a class based on the grades of 50 students in the class. …

## Application of Arrays

Application of Arrays Whenever we require a collection of data objects of the same type and want to process them as a single unit, an array can be used, provided the number of data items is constant or fixed. Arrays have a wide range of applications ranging from business data processing to scientific calculations to …

## Array Manipulation

Array Manipulation Shown next are C programs for carrying out manipulations such as finding the sum of elements of an array, adding two arrays, and reversing an array. Program ADDITION OF THE ELEMENTS OF THE LIST #include<stdio.h> #include<conio.h> void main() { void read(int *,int); void dis(int *,int); int a,i,sum=0;   clrscr(); printf(“Enter the elements of …

## What is Merging Array?

Merging Array Assume that two lists to be merged are sorted in descending order. Compare the first element of the first list with the first element of the second list. If the element of the first list is greater, then place it in the resultant list. Advance the index of the first list and the …

## What is Sorting Arrays?

Sorting Arrays We encounter several applications that require an ordered list. So it is required to order the elements of a given list either in ascending/increasing order or descending/decreasing order, as per the requirement. This process is called sorting. Sorting Array using Bubble Sort Bubble sorting is a simple sorting technique in which we arrange the elements of the list …

## Introduction to Stack and Queue

There are many applications requiring the use of the data structures stacks and queues. The most striking use of a data structure stack is the runtime stack that a programming language uses to implement a function call and return. Similarly, one of the important uses of a data structure queue is the process queue maintained …

## Working with Stacks | Stack and Queue Data Structure

Working with Stacks A stack is simply a list of elements with insertions and deletions permitted at one end—called the stack top. That means that it is possible to remove elements from a stack in reverse order from the insertion of elements into the stack. Thus, a stack data structure exhibits the LIFO (last in first out) property. Push and pop are the operations that are provided for …

## Working with Queues | Stack and Queue Data Structure

Working with Queues One of the applications of the stack is in expression evaluation. A complex assignment statement such as a = b + c*d/e–f may be interpreted in many different ways. Therefore, to give a unique meaning, the precedence and associativity rules are used. But still it is difficult to evaluate an expression by computer in …

A linked list is one of the fundamental data structures, and can be used to implement other data structures. It consists of a sequence of nodes, each containing arbitrary data fields and one or two references (“links”) pointing to the next and/or previous nodes. The principal benefit of a linked list over a conventional array …

## Inserting a Node | Linked List Data Structure

Inserting a Node A linked list is a recursive data structure. A recursive data structure is a data structure that has the same form regardless of the size of the data. You can easily write recursive programs for such data structures. Example Program # include <stdio.h> # include <stdlib.h> struct node { int data; struct …

Sorting and Reversing Link List Introduction To sort a linked list, first we traverse the list searching for the node with a minimum data value. Then we remove that node and append it to another list which is initially empty. We repeat this process with the remaining list until the list becomes empty, and at …

## Counting No. of Nodes in a List | Linked List Data Structure

Counting the number of nodes of a singly linked list requires maintaining a counter that is initialized to 0 and incremented by 1 each time a node is encountered in the process of traversing a list from the start. Here is a complete program that counts the number of nodes in a singly linked chain p, where p is a pointer to the …

## Deleting a Node from Link List | Linked List Data Structure

To delete a node, first we determine the node number to be deleted (this is based on the assumption that the nodes of the list are numbered serially from 1 to n). The list is then traversed to get a pointer to the node whose number is given, as well as a pointer to a …