SINGLE LINKED LIST. Algorithm for allocating memory for the new node
|
|
- Rosalind Wilkinson
- 5 years ago
- Views:
Transcription
1 SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA SCSVMV UNIVERSITY DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Faculty: S.Gokulakrishnan AP/CSE SINGLE LINKED LIST Aim:- Write a C program to implement single linked list. Algorithm: Algorithm for declaration of structure NODE Struct NODE DATA : Data Field LINK: Link Field (Address of next struct NODE) End Struct Algorithm for allocating memory for the new node GETNODE() Size: integer; newnode:node Step 1: Set SIZE = get the size of the NODE STEP 2: Set NEWNODE = Allocate space in memory for the size of size and return the initial address STEP 3: NEWNODE End GETNODE()
2 Algorithm For Reading The Content For The New Node READNODE(NEWNODE: NODE) STEP 1:Read, NEWNODE DATA STEP 2: Set NEWNODE LINK = NULL STEP 3: End READNODE() Algorithm for CREATELIST () CREATELIST() HEAD, LAST, NEWNODE:NODE STEP1: Set NEWNODE = GETNODE() STEP 2: CALL READNODE(NEWNODE) STEP 3: Set HEAD = NEWNODE STEP 4: Set LAST = NEWNODE STEP 5: If you want to add another NODE proceed otherwise STOP STEP 6: Set NEWNODE = GETNODE() STEP 7: CALL READNODE(NEWNODE) STEP 8: Assign LAST LINK = NEWNODE STEP 9: Assign LAST = LAST LINK STEP 10: Goto STEP 5 END CREATELIST()
3 Algorithm for inserting a node as the first node in the list INSERT_FIRST(HEAD : NODE) NEWNODE:NODE STEP1 : Set NEWNODE = GETNODE() STEP 2: CALL READNODE (NEWNODE) STEP 3: If(HEAD= = NULL) Set HEAD = NEWNODE STEP 4: Assign NEWNODE LINK = HEAD STEP 5: Set HEAD = NEWNODE END INSERT_FIRST() Algorithm for inserting a node as the last node in the list LAST, NEWNODE: NODE STEP 1: Set NEWNODE = GETNODE() STEP 2: CALL READNODE(NEWNODE) STEP 3: If(HEAD = = NULL) Set HEAD = NEWNODE STEP 4: Set LAST = HEAD STEP 5: Repeat While (LAST LINK!= NULL) Assign LAST = LAST LINK [End of While Structure] STEP 6: Assign LAST LINK = NEWNODE END INSERT_LAST()
4 Algorithm for inserting a node at any intermediate position in the list INSERT_MIDDLE (HEAD:NODE) LAST,NEWNODE:NODE CONDITION:DATA of the any one NODE in the LIST for insert STEP 1: Set NEWNODE = GETNODE() STEP 2: CALL READNODE(NEWNODE) STEP 3: If(HEAD = = NULL) Set HEAD = NEWNODE STEP 4: Print, Enter the data of NODE after which the insertion is to be made STEP 5: READ, CONDITION STEP 6: Set LAST = HEAD STEP 7: Repeat While(LAST!= NULL) STEP 8: If (LAST DATA == CONDITION ) Then Else Assign NEWNODE LINK = LAST LINK Assign LAST LINK = NEWNODE Assign LAST=LAST LINK STEP 9: [End of STEP 7 while structure] STEP 10: Print, CONDITION IS NOT AVAILABLE END INSERT_MIDDLE()
5 Algorithm for modifying an existing node MODIFY_NODE(HEAD:NODE) STEP1: If(HEAD==NULL) STEP 2: Print Enter the data of NODE to be modified STEP 3: Read CONDITION STEP 4: Set LAST = HEAD STEP 5: Repeat While(LAST!=NULL) STEP 6: If (LAST DATA == CONDITION) Then Read,LAST DATA Else Assign LAST = LAST LINK STEP 7: [End of STEP 5 while structure] STEP 8: Print, CONDITION IS NOT AVAILABLE END MODIFY_NODE() Algorithm for releasing the memory for the node to be deleted RELEASE_NODE(NEWNODE:NODE) STEP 1: Deallocate the space for the NODE of NEWNODE STEP 2: End RELEASENODE()
6 Algorithm For Deleting The First Node From The List DELETE_FIRST (HEAD:NODE) DELNODE: NODE STEP 1: If(HEAD== NULL) Print List is empty STEP 2: Set DELNODE= head STEP 3: Assign HEAD = HEAD LINK STEP 4: Print Deleted Data is, DELNODE DATA STEP 5: CALL RELEASENODE(DELNODE) END DELETE_FIRST () Algorithm for deleting the last node from the list DELETE_LAST(HEAD:NODE) LAST, PREV, DELNODE:NODE STEP 1: If(HEAD==NULL) Print List is empty STEP 2: If(HEAD LINK = = NULL) Then Set DELNODE = HEAD Set HEAD = NULL Print Deleted Data is, DELNODEDATA
7 STEP 3: Set LAST = HEAD STEP 4: Repeat While (LAST LINK!= NULL) STEP 5: Assign PREV = LAST STEP 6: Assign LAST = LAST LINK STEP 7: [End of STEP 4 While loop] STEP 8: Set DELNODE = LAST STEP 9: PREV LINK = NULL STEP 10: Print Deleted Data is, DELNODE DATA STEP 11: CALL RELEASENODE(DELNODE) END DELETE_LAST() Algorithm for deleting a node at any intermediate position in the list DELETE_MIDDLE(HEAD:NODE) LAST, PREV, DELNODE:NODE DELDATA: Data of the node is the NODE to Delete STEP 1: If(HEAD = = NULL) Print List is Empty STEP 2: Print Enter the DATA of the node in the list for deletion STEP 3: Read DELDATA STEP 4: If( HEAD DATA = = DELDATA) Then Set DELNODE = HEAD
8 Assign HEAD = HEAD LINK Print, Deleted Data is, DELNODE DATA CALL RELEASENODE(DELNODE) STEP 5: Set LAST = HEAD LINK STEP 6: Set PREV= HEAD STEP 7: Repeat While(LAST!= NULL) STEP 8: If( LAST DATA = = DELDATA) Then Set DELNODE = LAST Assign PREV LINK = LAST LINK Print The deleted Data is, DELNODE DATA CALL RELEASENODE(DELNODE) Else Assign LAST = LAST LINK Assign PREV = PREVLINK STEP 9: [End of STEP 7 While Loop] STEP 10: Print DELDATA is not available in the list END DELETE_MIDDLE()
9 Source Code: #include<stdio.h> #include<stdlib.h> #include<conio.h> typedef struct list int idno; struct list *link; node; node *newnode,*lastnode,*head,*midnode,*delnode; void create(); void insertfirst(); void insertlast(); void insertmiddle(); void deletefirst(); void deletelast(); void deletemiddle(); void display(); void main() int i; char ch; clrscr(); head=null; while(1)
10 printf("\nenter the choice: "); printf("\n1.create a list\n2.insert at first\n3.insert at last\n4.insert at middle\n5.delete at first\n6.delete at last\n7.delete at middle\n8.display\n?"); scanf("%d",&i); switch(i) case 1: case 2: case 3: case 4: case 5: case 6: case 7: create(); break; insertfirst(); break; insertlast(); break; insertmiddle(); break; deletefirst(); break; deletelast(); break; deletemiddle();
11 break; case 8: display(); break; default: exit(0); void create() char ch; printf("\n\ncreation\n\n"); do newnode=(node*)malloc(sizeof(node)); printf("\nenter the idno\n"); scanf("\t%d",&newnode->idno); newnode->link=null; if(head==null) head=newnode; else lastnode->link=newnode;
12 lastnode=newnode; printf("\ndo you want to cont...?\n"); ch=getche(); while((ch=='y') (ch=='y')); newnode->link=null; void insertfirst() printf("\n\ninsert AT FIRST\n\n"); newnode=(node*)malloc(sizeof(node)); printf("\nenter the idno :\n"); scanf("%d",&newnode->idno); if(head==null) head=newnode; newnode->link=null; else newnode->link=head; head=newnode; void insertlast()
13 printf("\ninsert AT LAST\n"); lastnode=(node*)malloc(sizeof(node)); printf("\nenter the idno"); scanf("%d",&lastnode->idno); lastnode->link=null; if(head==null) head=lastnode; else newnode=head; while(newnode->link!=null) newnode=newnode->link; newnode->link=lastnode; void insertmiddle() int data; printf("\n\ninsert AT MIDDLE\n\n"); newnode=(node*)malloc(sizeof(node)); printf("\nenter the idno\n"); scanf("%d",&newnode->idno); printf("\nenter the data of node after which insertion to be made\n"); scanf("%d",&data);
14 if(head==null) head=newnode; else lastnode=head; while(lastnode!=null) if(lastnode->idno==data) newnode->link=lastnode->link; lastnode->link=newnode; return; else lastnode=lastnode->link; printf("\ngiven data is not available\n"); void deletefirst() printf("\n\ndeleting AT FIRST\n"); if(head==null)
15 printf("\nlist is empty\n"); return; delnode=head; head=delnode->link; printf("deleted data is %d",delnode->idno); free(delnode); void deletelast() node *prevnode; printf("\n\ndeleting AT LAST\n"); if(head==null) printf("\nlist is empty\n"); return; else delnode=head; while(delnode->link!=null) prevnode=delnode; delnode=delnode->link; if(head==delnode)
16 head=null; printf("\ndeleted node is %d",delnode->idno); free(delnode); prevnode->link=null; printf("\ndeleted data is %d\n",delnode->idno); free(delnode); void deletemiddle() node *prevnode; int data; printf("\n\ndeleting AT MIDDLE\n"); if(head==null) printf("\nlist is empty\n"); return; delnode=head; printf("\nenter the data of node in list for deleting on\n"); scanf("%d",&data); if(head->idno==data) head=head->link;
17 printf("\ndeleted data is %d\n",delnode->idno); free(delnode); return; else delnode=head->link; prevnode=head; while(delnode!=null) if(delnode->idno==data) prevnode->link=delnode->link; printf("\ndeleted data is %d\n", delnode->idno); free(delnode); return; else delnode=delnode->link; prevnode=prevnode->link; printf("\ndata is not found\n");
18 void display() int count=0; printf("\n\ndisplaying\n\n"); if(head==null) printf("\nlist is empty\n"); printf("\n count = %d ",count); return; else newnode=head; for(;newnode!=null;newnode=newnode->link) count=count+1; printf("-->%d",newnode->idno); printf("\t\tcount = %d \n",count);
19 OUTPUT: Enter the choice: 1.Create a list 2.Insert at first 3.Insert at last 4.Insert at middle 5.Delete at first 6.Delete at last 7.Delete at middle 8.Display?1 CREATION Enter the idno 2 Do you want to cont...? y Enter the idno 4 Do you want to cont...? y
20 Enter the idno 6 Do you want to cont...? n Enter the choice: 1.Create a list 2.Insert at first 3.Insert at last 4.Insert at middle 5.Delete at first 6.Delete at last 7.Delete at middle 8.Display?8 DISPLAYING -->2-->4-->6 Count = 3 Enter the choice:?2 INSERT AT FIRST Enter the idno : 1
21 Enter the choice:?3 INSERT AT LAST Enter the idno7 Enter the choice:?4 INSERT AT MIDDLE Enter the idno 3 Enter the data of node after which insertion to be made 2 Enter the choice:?5 DELETING AT FIRST Deleted data is 1 Enter the choice:?6 DELETING AT LAST
22 Deleted data is 7 Enter the choice:?7 DELETING AT MIDDLE Enter the data of node in list for deleting on 3 Deleted data is 3 Enter the choice:?8 DISPLAYING -->2-->4-->6 Count = 3
SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA (UNIVERSITY ESTABLISHED UNDER SECTION 3 OF UGC ACT 1956) ENATHUR - KANCHIPURAM
SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA (UNIVERSITY ESTABLISHED UNDER SECTION 3 OF UGC ACT 1956) ENATHUR - KANCHIPURAM 631 561 DATA STRUCTURES LAB LABORATORY RECORD Name : Register. No :
More informationSRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA (UNIVERSITY ESTABLISHED UNDER SECTION 3 OF UGC ACT 1956) ENATHUR - KANCHIPURAM
SRI CHANDRASEKHARENDRA SARASWATHI VISWA MAHAVIDYALAYA (UNIVERSITY ESTABLISHED UNDER SECTION 3 OF UGC ACT 1956) ENATHUR - KANCHIPURAM 631 561 DATA STRUCTURES LAB LABORATORY RECORD Name : Register. No :
More informationLinked List in Data Structure. By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra
Linked List in Data Structure By Prof. B J Gorad, BECSE, M.Tech CST, PHD(CSE)* Assistant Professor, CSE, SITCOE, Ichalkaranji,Kolhapur, Maharashtra Linked List Like arrays, Linked List is a linear data
More informationCase Control Structure. Rab Nawaz Jadoon DCS. Assistant Professor. Department of Computer Science. COMSATS IIT, Abbottabad Pakistan
Case Control Structure DCS COMSATS Institute of Information Technology Rab Nawaz Jadoon Assistant Professor COMSATS IIT, Abbottabad Pakistan Introduction to Computer Programming (ICP) Decision control
More informationLecture 5: Outline. I. Multi- dimensional arrays II. Multi- level arrays III. Structures IV. Data alignment V. Linked Lists
Lecture 5: Outline I. Multi- dimensional arrays II. Multi- level arrays III. Structures IV. Data alignment V. Linked Lists Multidimensional arrays: 2D Declaration int a[3][4]; /*Conceptually 2D matrix
More informationLinked Lists and other Dynamic Data Structures
Linked Lists and other Dynamic Data Structures Arrays Fixed in size Allocated in advance within a contiguous memory block Look-up is fast Resizing and Deleting is hard (reallocate and copy) Dynamic Data
More informationModule III. Linear Data Structures and their Linked Storage Representation
Module III Linear Data Structures and their Linked Storage Representation 3.1 Linked List Linked list is the collection of inter connected nodes with a head node representing the first node and a tail
More informationAIM:- To write a C program to create a singly linked list implementation.
SINGLY LINKED LIST AIM:- To write a C program to create a singly linked list implementation. ALGORITHM:- 1. Start the program. 2. Get the choice from the user. 3. If the choice is to add records, get the
More informationAssignment 6. Q1. Create a database of students using structures, where in each entry of the database will have the following fields:
Assignment 6 Q1. Create a database of students using structures, where in each entry of the database will have the following fields: 1. a name, which is a string with at most 128 characters 2. their marks
More informationThe combination of pointers, structs, and dynamic memory allocation allow for creation of data structures
Data Structures in C C Programming and Software Tools N.C. State Department of Computer Science Data Structures in C The combination of pointers, structs, and dynamic memory allocation allow for creation
More informationProcedural Programming
Exercise 6 (SS 2016) 04.07.2015 What will I learn in the 6. exercise Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Home exercise 4 (3 points) Write a program which is able to handle
More informationSolution for Data Structure
Solution for Data Structure May 2016 INDEX Q1 a 2-3 b 4 c. 4-6 d 7 Q2- a 8-12 b 12-14 Q3 a 15-18 b 18-22 Q4- a 22-35 B..N.A Q5 a 36-38 b N.A Q6- a 39-42 b 43 1 www.brainheaters.in Q1) Ans: (a) Define ADT
More informationMODULE V: POINTERS & PREPROCESSORS
MODULE V: POINTERS & PREPROCESSORS INTRODUCTION As you know, every variable is a memory-location and every memory-location has its address defined which can be accessed using ampersand(&) operator, which
More informationAPS105. Structures 11/18/2013. Example A struct of stock items at a store: Structures. Lists. Arrays allow a collection of elements
APS105 Lists Structures Textbook Chapters 10.1, 10.3, 10.4, 10.6 2 Structures Arrays allow a collection of elements All of the same type How to collect elements of different types? Structures; in C: struct
More informationDownloaded from : Algorithm: Implementation QUESTION 1 :
QUESTION 1 : WRITE AN ALGORITHM THAT ACCEPTS A BINARY TREE AS INPUT AND PR INTS ITS HEIGHT TO STANDARD OUTPUT. Algorithm: 1. If tree is empty then return 0 2. Else (a) Get the max depth of left subtree
More informationData accessing is faster because we just need to specify the array name and the index of the element to be accssed.. ie arrays are simple to use
Module 3 Linear data structures and linked storage representation Advantages of arrays Linear data structures such as stacks and queues can be represented and implemented using sequential allocation ie
More information/* Polynomial Expressions Using Linked List*/ #include<stdio.h> #include<conio.h> #include <malloc.h> struct node. int num; int coeff;
/* Polynomial Expressions Using Linked List*/ #include #include #include struct node int num; int coeff; struct node *next; ; struct node *start1 = NULL; struct node *start2
More informationDEV BHOOMI INSTITUTE OF TECHNOLOGY
DEV BHOOMI INSTITUTE OF TECHNOLOGY Department of Computer Science and Engineering Year: 2nd Semester: 3rd Data Structures- PCS-303 LAB MANUAL Prepared By: HOD(CSE) DEV BHOOMI
More informationFundamentals of Programming & Procedural Programming
Universität Duisburg-Essen PRACTICAL TRAINING TO THE LECTURE Fundamentals of Programming & Procedural Programming Session Eight: Math Functions, Linked Lists, and Binary Trees Name: First Name: Tutor:
More information/****************************************** Application: Linked List Example Compiled on: Borland Turbo C++ 3.0
/****************************************** Application: Linked List Example Compiled on: Borland Turbo C++ 3.0 ******************************************/ #include #include /* Structure
More informationThis document can be downloaded from with most recent updates. 1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS
1 Data Structures using C: Module 4 (16MCA11) LINKED LISTS 4.1 MEMORY MANAGEMENT 4.1.1 Basics about Memory When a C program is compiled, the compiler translates the source code into machine code. Now the
More informationint marks[10]; // fixed size and fixed address No change in Memory address.
Dynamic Memory Allocation : Used When we want to allocate memory during run time. int marks[10]; // fixed size and fixed address No change in Memory address. // fixed size. ( no change in size possible
More informationDynamic Memory Allocation
Dynamic Memory Allocation The process of allocating memory at run time is known as dynamic memory allocation. C does not Inherently have this facility, there are four library routines known as memory management
More informationHomework Assignment #1
CISC 2200 Data Structure Spring, 2016 Homework Assignment #1 1 Short practices on linked list, see Textbook Page 205, Problem 9-12 2 Pointers: operations (deference, address-of), and syntax errors (a)
More informationSubject: Fundamental of Computer Programming 2068
Subject: Fundamental of Computer Programming 2068 1 Write an algorithm and flowchart to determine whether a given integer is odd or even and explain it. Algorithm Step 1: Start Step 2: Read a Step 3: Find
More informationCPSC 261 Midterm 2 Thursday March 17 th, 2016
CPSC 261 Midterm 2 Thursday March 17 th, 2016 [9] 1. Multiple choices [5] (a) Among the following terms, circle all of those that refer to a responsibility of a thread scheduler: Solution : Avoiding deadlocks
More informationFunctions:"" Breaking"large"computing"tasks"to" smaller"ones"
Lecture'3'(P a rt1):'''''''' ' 0 3 ' C 'Programm E S C ing'' 1 Functions:"" Breaking"large"computing"tasks"to" smaller"ones" 2 C'Programming' 'Procedural'thought'process' main%()%/*%high%level%outline%*/%
More informationProcedural Programming & Fundamentals of Programming
& Fundamentals of Programming Exercise 4 (SS 2018) 12.06.2018 What will I learn in the 5. exercise Files Math functions Dynamic data structures (linked Lists) Exercise(s) 1 Files A file can be seen as
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 LINKED LISTS LINKED LIST What are the problems with arrays? üsize is fixed üarray items are stored contiguously üinsertions and deletions at particular positions is complex
More informationChapter 19 Data Structures
Chapter 19 Data Structures Img src: reddit.com/r/programmerhumor 19-2 Data Structures A data structure is a particular organization of data in memory. We want to group related items together. We want to
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)
WINTER 18 EXAMINATION Subject Name: Data Structure using C Model wer Subject Code: 22317 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given
More informationVariables Data types Variable I/O. C introduction. Variables. Variables 1 / 14
C introduction Variables Variables 1 / 14 Contents Variables Data types Variable I/O Variables 2 / 14 Usage Declaration: t y p e i d e n t i f i e r ; Assignment: i d e n t i f i e r = v a l u e ; Definition
More informationBinary Search Tree 1.0. Generated by Doxygen Mon Jun :12:39
Binary Search Tree 1.0 Generated by Doxygen 1.7.1 Mon Jun 6 2011 16:12:39 Contents 1 Binary Search Tree Program 1 1.1 Introduction.......................................... 1 2 Data Structure Index 3
More informationESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees. Introduction to Linked Lists
ESc101: (Linear, Circular, Doubly) Linked Lists, Stacks, Queues, Trees Instructor: Krithika Venkataramani Semester 2, 2011-2012 1 Introduction to Linked Lists Each bead connected to the next through a
More informationUNIT 4: Linked List Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru.
UNIT 4: Linked List Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru. 1 Table of Contents 1. Array Implementation of Linked List...3 2. Queue using Array Implementation
More information/*Addition of two polynomials*/ #include<stdio.h> #include<malloc.h> #include<conio.h> struct link { int coeff; int pow; struct link *next; }; struct
/*Addition of two polynomials*/ #include #include #include struct link int coeff; int pow; struct link *next; ; struct link *poly1=null,*poly2=null,*poly=null; void create(struct
More informationDS Lab Manual -17CS33
Chethan Raj C Assistant Professor Dept. of CSE 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
More informationLinked List using a Sentinel
Linked List using a Sentinel Linked List.h / Linked List.h Using a sentinel for search Created by Enoch Hwang on 2/1/10. Copyright 2010 La Sierra University. All rights reserved. / #include
More informationChapter 19 Data Structures -struct -dynamic memory allocation
Chapter 19 Data Structures -struct -dynamic memory allocation Data Structures A data structure is a particular organization of data in memory. We want to group related items together. We want to organize
More informationLinked List. April 2, 2007 Programming and Data Structure 1
Linked List April 2, 2007 Programming and Data Structure 1 Introduction head A linked list is a data structure which can change during execution. Successive elements are connected by pointers. Last element
More informationPointers. Array. Solution to the data movement in sequential representation
1 LISTS Pointers Array sequential representation some operation can be very time-consuming (data movement) size of data must be predefined static storage allocation and deallocation Solution to the data
More informationDynamic Memory Allocation and Linked Lists
CSE 2421: Systems I Low-Level Programming and Computer Organization Dynamic Memory Allocation and Linked Lists Presentation I Read/Study: Reek Chapter 11 & 12 Gojko Babić 02-26-2017 Functions malloc and
More informationVariation of Pointers
Variation of Pointers A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before
More informationBit Manipulation in C
Bit Manipulation in C Bit Manipulation in C C provides six bitwise operators for bit manipulation. These operators act on integral operands (char, short, int and long) represented as a string of binary
More informationMODULE 1. Introduction to Data Structures
MODULE 1 Introduction to Data Structures Data Structure is a way of collecting and organizing data in such a way that we can perform operations on these data in an effective way. Data Structures is about
More informationChapter 6. Data Structure. /* start contains the address of the first node */ start = &elephant1; print_elephants( start ); return EXIT_SUCCESS;
Chapter 6 Data Structure Introductory notes are included in PowerPoint file. The programs illustrated are as follows: //elephnt1.c // This example is from C for Scientists and Engineers #include
More informationData Structure Series
Data Structure Series This series is actually something I started back when I was part of the Sweet.Oblivion staff, but then some things happened and I was no longer able to complete it. So now, after
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 16 EXAMINATION Model Answer Subject Code:
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate
More informationIntroduction to Data Structures. Systems Programming
Introduction to Data Structures Systems Programming Intro to Data Structures Self-referential Structures Dynamic Memory Allocation A Simple malloc Example Linear Lists Linked Lists Insertion Example Linked
More informationCS32 - Week 2. Umut Oztok. July 1, Umut Oztok CS32 - Week 2
CS32 - Week 2 Umut Oztok July 1, 2016 Arrays A basic data structure (commonly used). Organize data in a sequential way. Arrays A basic data structure (commonly used). Organize data in a sequential way.
More informationC++ - Lesson 2 This is a function prototype. a' is a function that takes an integer array argument and returns an integer pointer.
C++ - Lesson 2 1. Explain the following declarations: a) int *a(int a[]); This is a function prototype. 'a' is a function that takes an integer array argument and returns an integer pointer. b) const char
More information19-Nov CSCI 2132 Software Development Lecture 29: Linked Lists. Faculty of Computer Science, Dalhousie University Heap (Free Store)
Lecture 29 p.1 Faculty of Computer Science, Dalhousie University CSCI 2132 Software Development Lecture 29: Linked Lists 19-Nov-2018 Location: Chemistry 125 Time: 12:35 13:25 Instructor: Vlado Keselj Previous
More informationComputer Systems and Networks
University of the Pacific LECTURE 5: C PROGRAMMING Computer Systems and Networks Dr. Pallipuram (vpallipuramkrishnamani@pacific.edu) Today s Class o Pointer basics o Pointers and mul;- dimensional arrays
More informationCIS 190: C/C++ Programming. Linked Lists
CIS 190: C/C++ Programming Linked Lists Why Use Linked Lists? solve many of the problems arrays have like Problems with Arrays arrays have a fixed size may be too large, or too small arrays must be held
More informationUnited States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017
United States Naval Academy Electrical and Computer Engineering Department EC310-6 Week Midterm Spring AY2017 1. Do a page check: you should have 8 pages including this cover sheet. 2. You have 50 minutes
More informationUNIT IV 4 LINKED LIST
4 UNIT IV LINKED LIST LINKED LIST SYLLABUS: 4.1 Pointers Revision 4.2 Revision of Structure 4.3 Revision of structure using pointers 4.4 Dynamic Memory Allocation 4.5 Linked list Presentation 4.6 Types
More informationComputer Programming Unit v
READING AND WRITING CHARACTERS We can read and write a character on screen using printf() and scanf() function but this is not applicable in all situations. In C programming language some function are
More informationLesson 6.1: Structs. This declares a collection of two integer variables to denote the two coordinates of a point in a plane.
Lesson 6.1: Structs Programming in C Prof. Dr. Eike Best Dr. Elke Wilkeit October 12, 2002 1 struct point { 2 int x; 3 int y; 4 }; This declares a collection of two integer variables to denote the two
More informationWhat is recursion. WAP to find sum of n natural numbers using recursion (5)
DEC 2014 Q1 a What is recursion. WAP to find sum of n natural numbers using recursion (5) Recursion is a phenomenon in which a function calls itself. A function which calls itself is called recursive function.
More informationData Structures and Algorithms. Chapter 5. Dynamic Data Structures and Abstract Data Types
1 Data Structures and Algorithms Chapter 5 and Abstract Data Types Werner Nutt 2 Acknowledgments The course follows the book Introduction to Algorithms, by Cormen, Leiserson, Rivest and Stein, MIT Press
More informationSTACKS 3.1 INTRODUCTION 3.2 DEFINITION
STACKS 3 3.1 INTRODUCTION A stack is a linear data structure. It is very useful in many applications of computer science. It is a list in which all insertions and deletions are made at one end, called
More informationMemory. What is memory? How is memory organized? Storage for variables, data, code etc. Text (Code) Data (Constants) BSS (Global and static variables)
Memory Allocation Memory What is memory? Storage for variables, data, code etc. How is memory organized? Text (Code) Data (Constants) BSS (Global and static variables) Text Data BSS Heap Stack (Local variables)
More informationThe output will be: marks all or nothing. 1 #include <stdio.h> 2 main() { 3 int i; int j; 4 int *p; int *q; 6 p = &i; 7 q = &j; 8 i = 1;
p. 2 of 9 Q1. [5 marks] The following program compiles and runs with no problems. Indicate what the output of the program is going to be (no explanation necessary). 1 #include 2 main() { 3 int
More informationAnswer all questions. Write your answers only in the space provided. Full marks = 50
Answer all questions. Write your answers only in the space provided. Full marks = 50 1. Answer the following: [2+3+2+1=8 marks] a) What are the minimum and maximum numbers that can be represented in 10-bit
More informationCSCE 110 PROGRAMMING FUNDAMENTALS
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 16. Linked Lists Prof. amr Goneid, AUC 1 Linked Lists Prof. amr Goneid, AUC 2 Linked Lists The Linked List Structure Some Linked List
More information! A data structure representing a list. ! A series of nodes chained together in sequence. ! A separate pointer (the head) points to the first
Ch. 17: Linked Lists 17.1 Introduction to Linked Lists! A data structure representing a list! A series of nodes chained together in sequence CS 2308 Spring 2013 Jill Seaman - Each node points to one other
More informationEECE.2160: ECE Application Programming
Summer 2017 Programming Assignment #9: Doubly-Linked Lists Due Monday, 6/26/17, 11:59:59 PM (+15% if submitted by 6/23, +10% if submitted 6/24-6/25, +5% if submitted 6/26) 1. Introduction This assignment
More informationNow consider the following situation after deleting three elements from the queue...
Scheme of valuvation -1I Subject & Code : Data Structure and Application (15CS33) NOTE: ANSWER All FIVE QUESTIONS 1 Explain the diadvantage of linear queue and how it i olved in circular queue. Explain
More informationPrepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon
Data Structures &Al Algorithms Prepared By:- Dinesh Sharma Asstt. Professor, CSE & IT Deptt. ITM Gurgaon What is Data Structure Data Structure is a logical relationship existing between individual elements
More informationDC54 DATA STRUCTURES DEC 2014
Q.2 a. Write a function that computes x^y using Recursion. The property that x^y is simply a product of x and x^(y-1 ). For example, 5^4= 5 * 5^3. The recursive definition of x^y can be represented as
More informationDarshan Institute of Engineering & Technology for Diploma studies Unit 4
Pointer A pointer is a variable that contains address or location of another variable. Pointer is a derived data type in C. Pointers contain memory address as their values, so they can also be used to
More informationDATA STRUCTURES USING C
DATA STRUCTURES USING C DATA STRUCTURES USING C LECTURE NOTES Prepared by Dr. Subasish Mohapatra Department of Computer Science and Application College of Engineering and Technology, Bhubaneswar Biju Patnaik
More informationINTRODUCTION TO DATA STRUCTURES
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
More informationDATA STRUCTURES LABORATORY
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
More informationPOLYNOMIAL ADDITION. AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition.
POLYNOMIAL ADDITION AIM:- To write a C program to represent a polynomial as a linked list and write functions for polynomial addition. ALGORITHM:- 1. Start the program 2. Get the coefficients and powers
More informationUNIT VI. STACKS AND QUEUES
UNIT VI. STACKS AND QUEUES Syllabus: /*-------------------------------------------------------------------------*/ Stack: Definition: "Stack is an ordered collection of data elements having similar data
More informationUnit 3 Decision making, Looping and Arrays
Unit 3 Decision making, Looping and Arrays Decision Making During programming, we have a number of situations where we may have to change the order of execution of statements based on certain conditions.
More informationChapter 4: Lists 2004 년가을학기. 강경란 정보및컴퓨터공학부, 아주대학교
Chapter 4: Lists 2004 년가을학기 강경란 korykang@ajou.ac.kr 정보및컴퓨터공학부, 아주대학교 1. Pointers 2. Singly Linked Lists Chapter 4 Lists 3. Dynamically Linked Stacks and Queues 4. Polynomials 5. Additional List Operations
More informationDoubly Linked List Methodology and Program
Doubly Linked List Methodology and Program Semester 3: Data Structures This document is for private circulation for the students of Navlakhi. More educational content can be found on www.navlakhi.com and
More informationClass Information ANNOUCEMENTS
Class Information ANNOUCEMENTS Third homework due TODAY at 11:59pm. Extension? First project has been posted, due Monday October 23, 11:59pm. Midterm exam: Friday, October 27, in class. Don t forget to
More informationUNIT 3: QUEUE Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru.
UNIT 3: QUEUE Programs demonstrated in class. Tojo Mathew Asst. Professor CSE Dept., NIE Mysuru. Table of Contents 1. Simple Queue Implementation with arrays...3 2. Circular queue with global container
More informationData Structures and Algorithms. Roberto Sebastiani
Data Structures and Algorithms Roberto Sebastiani roberto.sebastiani@disi.unitn.it http://www.disi.unitn.it/~rseba - Week 05 - B.S. In Applied Computer Science Free University of Bozen/Bolzano academic
More informationA3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE
A3-R3: PROGRAMMING AND PROBLEM SOLVING THROUGH 'C' LANGUAGE NOTE: 1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions and PART TWO contains FIVE questions. 2. PART ONE is to be
More informationCS 2113 Software Engineering
CS 2113 Software Engineering Do this now!!! From C to Java git clone https://github.com/cs2113f18/c-to-java.git cd c-to-java./install_java Professor Tim Wood - The George Washington University We finished
More informationM1-R4: Programing and Problem Solving using C (JAN 2019)
M1-R4: Programing and Problem Solving using C (JAN 2019) Max Marks: 100 M1-R4-07-18 DURATION: 03 Hrs 1. Each question below gives a multiple choice of answers. Choose the most appropriate one and enter
More informationFlow Control. CSC215 Lecture
Flow Control CSC215 Lecture Outline Blocks and compound statements Conditional statements if - statement if-else - statement switch - statement? : opertator Nested conditional statements Repetitive statements
More informationUNIT - V STRUCTURES AND UNIONS
UNIT - V STRUCTURES AND UNIONS STRUCTURE DEFINITION A structure definition creates a format that may be used to declare structure variables. Let us use an example to illustrate the process of structure
More informationData Structures (CS301) LAB
Data Structures (CS301) LAB Objectives The objectives of this LAB are, o Enabling students to implement Doubly Linked List practically using c++ and adding more functionality in it. Introduction to Singly
More informationPROGRAMMAZIONE I A.A. 2017/2018
PROGRAMMAZIONE I A.A. 2017/2018 FUNCTIONS INTRODUCTION AND MAIN All the instructions of a C program are contained in functions. üc is a procedural language üeach function performs a certain task A special
More informationComputers Programming Course 12. Iulian Năstac
Computers Programming Course 12 Iulian Năstac Recap from previous course Strings in C The character string is one of the most widely used applications that involves vectors. A string in C is an array of
More informationEECE.2160: ECE Application Programming
Fall 2017 Programming Assignment #10: Doubly-Linked Lists Due Monday, 12/18/17, 11:59:59 PM (Extra credit ( 5 pts on final average), no late submissions or resubmissions) 1. Introduction This assignment
More informationStructures, Pointers, Linked Lists
Lecture 6: Structures, Pointers, Linked Lists Reminder: Pointers and structures Pointers to structures Dynamic memory allocation: malloc Linked lists Ordered linked lists Double linked lists, Trees Reminder:
More informationHere's how you declare a function that returns a pointer to a character:
23 of 40 3/28/2013 10:35 PM Violets are blue Roses are red C has been around, But it is new to you! ANALYSIS: Lines 32 and 33 in main() prompt the user for the desired sort order. The value entered is
More informationName :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70
Name :. Roll No. :..... Invigilator s Signature :.. 2011 INTRODUCTION TO PROGRAMMING Time Allotted : 3 Hours Full Marks : 70 The figures in the margin indicate full marks. Candidates are required to give
More informationTest Paper 1 Programming Language 1(a) What is a variable and value of a variable? A variable is an identifier and declared in a program which hold a value defined by its type e.g. integer, character etc.
More informationSpring 2008 Data Structures (CS301) LAB
Spring 2008 Data Structures (CS301) LAB Objectives The objectives of this LAB are, o Enabling students to implement Singly Linked List practically using c++ and adding more functionality in it. o Enabling
More informationCOP Programming Concepts Spring 1999 CLOSED BOOK Exam #1 100 Points NAME
CLOSED BOOK Exam #1 100 Points NAME 1. The following program has (at least) 10 syntax errors. Circle each error. Write the corrected program in the blank space below. 2 points for each error you find.
More informationMTH 307/417/515 Final Exam Solutions
MTH 307/417/515 Final Exam Solutions 1. Write the output for the following programs. Explain the reasoning behind your answer. (a) #include int main() int n; for(n = 7; n!= 0; n--) printf("n =
More informationTrees CONTENTS. Hours: 8. Marks: 12. Anuradha Bhatia 1
Trees CONTENTS 6.1 Introduction 1. Terminologies: tree,degree of a node, degree of a tree, level of a node, leaf node, Depth / Height of a tree, In-degree & out- Degree, Directed edge, Path, Ancestor &
More informationA506 / C201 Computer Programming II Placement Exam Sample Questions. For each of the following, choose the most appropriate answer (2pts each).
A506 / C201 Computer Programming II Placement Exam Sample Questions For each of the following, choose the most appropriate answer (2pts each). 1. Which of the following functions is causing a temporary
More information