Tuesday, October 24, 2017

INTRODUCTION TO DATA STRUCTURES

Data Structure is defined as the way in which data is organized in the memory location. There are 2 types of data structures:




Linear Data Structure: In linear data structure all the data are stored linearly or contiguously in the memory. All the data are saved in continuously memory locations and hence all data elements are saved in one boundary. A linear data structure is one in which we can reach directly only one element from another while travelling sequentially. The main advantage, we find the first element, and then it‟s easy to find the next data elements. The disadvantage, the size of the array must be known before allocating the memory. The different types of linear data structures are:
  • Array
  • Stack
  • Queue
  • Linked List


Non-Linear Data Structure: Every data item is attached to several other data items in a way that is specific for reflecting relationships. The data items are not arranged in a sequential structure. The various types of non linear data structures are:
  • Trees
  • Graphs 


Saturday, October 21, 2017

Data Structure

DATA STRUCTURES LABORATORY 
[As per Choice Based Credit System (CBCS) scheme] 
(Effective from the academic year 2015 -2016) 
SEMESTER – III 


Laboratory Code
15CSL38
IA Marks
20
Number of Lecture Hours/Week
01I + 02P
Exam Marks
80
Total Number of Lecture Hours
40
Exam Hours
03


Implement all the experiments in C Language under Linux / Windows environment.
Ex. No.
Laboratory Experiments Description
(RBT Levels: L3, L4, L5, L6)
Page
No.
Introduction to Data Structures
4
1
Design, Develop and Implement a menu driven Program in C for the following Arrayoperations
a.       Creating an Array of Integer Elements
b.       Display of Array Elements with Suitable Headings
c.        Inserting an Element (ELEM) at a given valid Position (POS)
d.       Deleting an Element at a given valid Position(POS)
e.        Exit.
Support the program with functions for each of the above operations.
5
2
Design, Develop and Implement a Program in C for the following operations on Strings
a.       Read a main String (STR), a Pattern String (PAT) and a Replace String (REP)
b.       Perform Pattern Matching Operation: Find and Replace all occurrences of PAT in STRwith REP if PAT exists in STR. Report suitable messages in case PAT does not exist in STR
Support the program with functions for each of the above operations. Don’t use Built-in functions.
9
3
Design, Develop and Implement a menu driven Program in C for the following operations on STACK of Integers (Array Implementation of Stack with maximum size MAX)
a.       Push an Element on to Stack
b.       Pop an Element from Stack
c.        Demonstrate how Stack can be used to check Palindrome
d.       Demonstrate Overflow and Underflowsituations on Stack
e.        Display the status of Stack
f.        Exit
Support the program with appropriate functions for each of the above operations
12
4
Design, Develop and Implement a Program in C for converting an Infix Expression to Postfix Expression. Program should support for both parenthesized and free parenthesized expressions with the operators: +, -, *, /, %( Remainder), ^ (Power) and alphanumericoperands.
18
5
Design, Develop and Implement a Program in C for the following Stack Applications
a. Evaluation of Suffix expression with single digit operands and operators: +, -, *, /, %, ^
 b. Solving Tower of Hanoi problem with ndisks
21
6
Design, Develop and Implement a menu driven Program in C for the following operations on Circular QUEUE of Characters (Array Implementation of Queue with maximum size MAX)
a.       Insert an Element on to Circular QUEUE
b.       Delete an Element from Circular QUEUE
c.        Demonstrate Overflow and Underflowsituations on Circular QUEUE
d.       Display the status of Circular QUEUE
e.        Exit
Support the program with appropriate functions for each of the above operations
26
7
Design, Develop and Implement a menu driven Program in C for the following operations on Singly Linked List (SLL) of Student Data with the fields: USN, Name, Branch, Sem, PhNo
a.       Create a SLL of Students Data by using front insertion.
b.       Display the status of SLL and count the number of nodes in it
c.        Perform Insertion and Deletion at End of SLL
d.       Perform Insertion and Deletion at Front of SLL
e.        Demonstrate how this SLL can be used as STACK and QUEUE
f.        Exit
30
8
Design, Develop and Implement a menu driven Program in C for the following operations on Doubly Linked List (DLL) of Employee Data with the fields: SSN, Name, Dept, Designation, Sal, PhNo
a.       Create a DLL of Employees Data by using end insertion.
b.       Display the status of DLL and count the number of nodes in it
c.        Perform Insertion and Deletion at End of DLL
d.       Perform Insertion and Deletion at Front of DLL
e.        Demonstrate how this DLL can be used as Double Ended Queue
f.        Exit
39
9
Design, Develop and Implement a Program in C for the following operations on Singly Circular
Linked List (SCLL) with header nodes
a. Represent and Evaluate a Polynomial P(x,y,z) = 6x2y2z-4yz5+3x3yz+2xy5z-2xyz3
b. Find the sum of two polynomials POLY1(x,y,z) and POLY2(x,y,z) and store the result in
POLYSUM(x,y,z)
Support the program with appropriate functions for each of the above operations
47
10
Design, Develop and Implement a menu driven Program in C for the following operations on Binary Search Tree (BST) of Integers
a.       Create a BST of Integers: 6, 9, 5, 2, 8, 15, 24, 14, 7, 8, 5, 2
b.       Traverse the BST in Inorder, Preorder and Post Order
c.        Search the BST for a given element (KEY) and report the appropriate message
d.       Delete an element(ELEM) from BST
a.       e. Exit
54
11
Design, Develop and Implement a Program in C for the following operations on Graph(G) of Cities
a.       Create a Graph of cities using Adjacency Matrix.
b.       Print all the nodes reachable from a given starting node in a digraph using BFSmethod
b.       c. Check whether a given graph is connected or not using DFS method.
61
12
Given a File of employee records with a set Kof Keys(4-digit) which uniquely determine the records in file F. Assume that file is maintained in memory by a Hash Table(HT) of memory locations with as the set of memory addresses (2-digit) of locations in HT. Let the keys in and addresses in are Integers. Design and develop a Program in C that uses Hash function H: K ®as H(K)=Kmod m (remainder method), and implement hashing technique to map a given key to the address space L. Resolve the collision (if any) using linear probing.
68

Viva Questions And Answers
74
Course outcomes: On the completion of this laboratory course, the students will be able to:
·         Analyze and Compare various linear and non-linear data structures
·         Code, debug and demonstrate the working nature of different types of data
·         structures and their applications
·         Implement, analyze and evaluate the searching and sorting algorithms
·         Choose the appropriate data structure for solving real world problems
Graduate Attributes (as per NBA)
1.       Engineering Knowledge
2.       Problem Analysis
3.       Design/Development of Solutions
4.       4. Modern Tool Usage
Conduction of Practical Examination:
1.       All laboratory experiments (TWELVE nos ) are to be included for practical examination.
2.       Students are allowed to pick one experiment from the lot.
3.       Strictly follow the instructions as printed on the cover page of answer script
4.       Marks distribution: Procedure + Conduction + Viva:20 + 50 +10 (80)
5.       Change of experiment is allowed only once and marks allotted to the procedure part to be made zero.


Wednesday, January 27, 2016

Write a C/C++ POSIX compliant program that prints the POSIX defined configuration options supported on any given system using feature test macros.

Theory :

POSIX allows an application to test at compile or run time whether certain options are supported, or what the value is of certain configurable constants or limits.
  • POSIX_SOURCE:If you define this macro, then the functionality from the POSIX.1 standard (IEEE Standard 1003.1) is available, as well as all of the ISO C facilities.
  • POSIX_C_SOURCE:Define this macro to a positive integer to control which POSIX functionality is made available. The greater the value of this macro, the more functionality is made available.
  • POSIX_JOB_CONTROL:If this symbol is defined, it indicates that the system supports job control. Otherwise, the implementation behaves as if all processes within a session belong to a single process group. See section Job Control.
  • POSIX_SAVED_IDS:If this symbol is defined, it indicates that the system remembers the effective user and group IDs of a process before it executes an executable file with the set-user-ID or set-group-ID bits set, and that explicitly changing the effective user or group IDs back to these values is permitted. If this option is not defined, then if a nonprivileged process changes its effective user or group ID to the real user or group ID of the process, it can't change it back again.
  • POSIX_CHOWN_RESTRICTED:If this option is in effect, the chown function is restricted so that the only changes permitted to nonprivileged processes is to change the group owner of a file to either be the effective group ID of the process, or one of its supplementary group IDs.
  • int _POSIX_NO_TRUNC:If this option is in effect, file name components longer than NAME_MAX generate an ENAMETOOLONG error. Otherwise, file name components that are too long are silently truncated.
  • POSIX_VDISABLE:This option is only meaningful for files that are terminal devices. If it is enabled, then handling for special control characters can be disabled individually.

Code:

#define _POSIX_SOURCE #define _POSIX_C_SOURCE 199309L #include "iostream" #include using namespace std; int main() { #ifdef _POSIX_JOB_CONTROL cout<<"System supports POSIX job control:"<<_posix_job_control endl="" span="">#else cout<<"System does not support POSIX job control"<#endif #ifdef _POSIX_SAVED_IDS cout<<"System supports saved set UID and GID:"<<_posix_saved_ids endl="" span="">#else cout<<"System does not support saved set GID and UID"<#endif #ifdef _POSIX_CHOWN_RESTRICTED cout<<"Chown restricted option is :"<<_posix_chown_restricted endl="" span="">#else cout<<"Chown Restricted not defined"<#endif #ifdef _POSIX_NO_TRUNC cout<<"Truncation option is :"<<_posix_no_trunc endl="" span="">#else cout<<"Truncation Option not defined"<#endif #ifdef _POSIX_VDISABLE cout<<"disable char for terminal files"<<_posix_vdisable endl="" span="">#else cout<<"char for terminal device files will not be diasbled"<#endif return 0; }


Output:

  • Open a terminal.
  • Change directory to the file location in the terminals.
  • Open a file using command followed by program_name
  • vi 02_posix_configuration.cpp
    and then enter the source code and save it.
  • Then compile the program using
  • g++ 02_posix_configuration.cpp
  • If there are no errors after compilation execute the program using
  • ./a.out