CS148 Introduction to Programming II

Slides:



Advertisements
Similar presentations
Linked Lists Mohammed Almashat CS /03/2006.
Advertisements

Linked Lists CSE 2451 Matt Boggus. Dynamic memory reminder Allocate memory during run-time malloc() and calloc() – return a void pointer to memory or.
Lecture 20: 11/12/2002CS170 Fall CS170 Computer Organization and Architecture I Ayman Abdel-Hamid Department of Computer Science Old Dominion University.
Chapter 17 Linked List Saurav Karmakar Spring 2007.
Lecture 18: 4/11/2003CS148 Spring CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Computer Programming Link List (Insertion, Printing and Deletion functions) Lecture 23.
Variations of Linked Lists CS 302 – Data Structures Sections 6.2, 6.3 and 6.4.
Introduction to Data Structure, Spring 2007 Slide- 1 California State University, Fresno Introduction to Data Structure Introduction of Concepts Ming Li.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 12 – Data Structures Outline 12.1Introduction.
Self Referential Structure. A structure may not contain a member of its own type. struct check { int item; struct check n; // Invalid };
Chapter 12 Data Structure Associate Prof. Yuh-Shyan Chen Dept. of Computer Science and Information Engineering National Chung-Cheng University.
Lecture 14 Linked Lists 14-1 Richard Gesick. Linked Lists Dynamic data structures can grow and shrink at execution time. A linked list is a linear collection.
CS 1031 Linked Lists Definition of Linked Lists Examples of Linked Lists Operations on Linked Lists Linked List as a Class Linked Lists as Implementations.
Department of Computer Science Data Structures Using C++ 2E Chapter 5 Linked Lists.
1 Data Structures CSCI 132, Spring 2014 Lecture 20 Linked Lists.
Review 1 Polish Notation Prefix Infix Postfix Precedence of Operators Converting Infix to Postfix Evaluating Postfix.
Programming Abstractions Cynthia Lee CS106X. Topics:  Priority Queue › Linked List implementation › Heap data structure implementation  TODAY’S TOPICS.
Lecture 10: 2/17/2003CS148 Spring CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture.
Copyright © 2012 Pearson Education, Inc. Chapter 20: Binary Trees.
Linked list: a list of items (nodes), in which the order of the nodes is determined by the address, called the link, stored in each node C++ Programming:
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Linked Lists Outline Introduction Self-Referential Structures.
Linked Lists Chapter Introduction To The Linked List ADT Linked list: set of data structures (nodes) that contain references to other data structures.
CS32 Discussion Section 1B Week 3 TA: Hao Yu (Cody)
Linked Lists Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University of Wisconsin.
UNIT-II Topics to be covered Singly linked list Circular linked list
Copyright © 2012 Pearson Education, Inc. Chapter 17: Linked Lists.
Linked Lists.
Lecture 6 of Computer Science II
C++ Programming:. Program Design Including
ECE Application Programming
Chapter 12 – Data Structures
5.13 Recursion Recursive functions Functions that call themselves
Lectures linked lists Chapter 6 of textbook
UNIT – I Linked Lists.
Linked Lists Chapter 6 Section 6.4 – 6.6
Review Deleting an Element from a Linked List Deletion involves:
Lecture No.06 Data Structures Dr. Sohail Aslam
Programming Abstractions
Sequences 9/18/ :20 PM C201: Linked List.
Tree data structure.
Chapter 20: Binary Trees.
LINKED LISTS CSCD Linked Lists.
Chapter 16-2 Linked Structures
Chapter 21: Binary Trees.
Data Structures and Analysis (COMP 410)
CS149D Elements of Computer Science
CS148 Introduction to Programming II
Arrays and Linked Lists
Tree data structure.
CS170 Computer Organization and Architecture I
Sequences 11/27/2018 1:37 AM Singly Linked Lists Singly Linked Lists.
كلية المجتمع الخرج البرمجة - المستوى الثاني
CS148 Introduction to Programming II
Review & Lab assignments
Chapter 17: Linked Lists.
Given value and sorted array, find index.
CS148 Introduction to Programming II
COMPUTER 2430 Object Oriented Programming and Data Structures I
CS148 Introduction to Programming II
CS148 Introduction to Programming II
CS149D Elements of Computer Science
Lecture No.02 Data Structures Dr. Sohail Aslam
CS149D Elements of Computer Science
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
CS148 Introduction to Programming II
CS148 Introduction to Programming II
CS148 Introduction to Programming II
COS 151 Bootcamp – Week 4 Department of Computer Science
Linked Lists.
CMPT 225 Lecture 5 – linked list.
Presentation transcript:

CS148 Introduction to Programming II Ayman Abdel-Hamid Department of Computer Science Old Dominion University Lecture 12: 2/24/2003 Lecture 12: 2/24/2003 CS148 Spring 2003

Outline Linked lists Operations on linked lists Insert at back Insert at front Lecture 12: 2/24/2003 CS148 Spring 2003

Linked Lists A list represented as an array is a sequential structure (successive components of the array are located next to each other in memory Efficient for searching in a sorted list using a binary search Insertion/deletion in a sorted array? A linked list is a collection of nodes. Nodes are scattered in memory, not in consecutive memory locations Each node is represented by a struct consisting of two main components Data Component (one or more struct members) Link Component (gives location of next node in the list) Lecture 12: 2/24/2003 CS148 Spring 2003

Linked Lists struct node { int ID; //Node ID string name; Data Component Link A node in a linked list struct node { int ID; //Node ID string name; node* next; //pointer to next node }; HEAD 1 2 (N-1) N points to NULL (the end of the list) A linked list (HEAD gives the location of the first node in the list) Lecture 12: 2/24/2003 CS148 Spring 2003

Insertion at back of list p HEAD NewNode struct node { int ID; //Node ID string name; node* next; //pointer to next node }; node *p,*NewNode; //allocate new node and fill NewNode = new node; NewNode->next = NULL; //link NewNode to the node pointed to by p p->next = NewNode; NewNode p Lecture 12: 2/24/2003 CS148 Spring 2003

Insertion at front of list NewNode HEAD struct node { int ID; //Node ID string name; node* next; //pointer to next node }; HEAD NewNode node *p,*NewNode; //allocate new node NewNode = new node; //make NewNode the first node in the list NewNode->next = HEAD; HEAD = NewNode; HEAD NewNode Lecture 12: 2/24/2003 CS148 Spring 2003