Lab Session-7 CSIT221 Fall 2002 - PowerPoint PPT Presentation

About This Presentation
Title:

Lab Session-7 CSIT221 Fall 2002

Description:

Example Usage of New Functions ... 'Please input value 5' user enters 37 (List is created in ascending order: 3,12,24,37,45) ... – PowerPoint PPT presentation

Number of Views:15
Avg rating:3.0/5.0
Slides: 7
Provided by: sunyfr
Category:
Tags: csit221 | fall | lab | session | usage

less

Transcript and Presenter's Notes

Title: Lab Session-7 CSIT221 Fall 2002


1
Lab Session-7 CSIT221 Fall 2002
  • Pointers, Pointers, Pointers
  • Example Program
  • Lab Exercise (Demo Required)

2
Pointers, Pointers, Pointers
  • We can build a linked queue, stack or list of
    multiple elements by using a struct at every node
  • This struct must contain a pointer that points to
    the next node
  • Look at the example program and draw a diagram
    showing the whole list

3
Example Program
  • struct NodeType
  • int info
  • NodeType next
  • NodeType Head, Location
  • Head new NodeType
  • Head-gtinfo 45
  • Location new NodeType
  • Location-gtinfo 32
  • Head-gtnext Location
  • Location-gtnext Head

4
Lab Exercise (Demo Due Oct 22 Sec 01 and Oct 24
Sec 02)
  • Implement a sorted linked list of integers using
    the specifications found in Chapter 5 of the
    textbook. Include 2 new member functions
    specified as below
  • Make_list(int length) function creates a list of
    size length and fills the values from the user
  • Delete_3(int val) function deletes three elements
    from the list starting at the node containing
    val
  • Examples are shown in the following slides

5
Example Usage of New Functions
  • Call the function Make_list(5) and this is what
    is displayed by the function
  • Welcome!! We are building a list of 5 values
  • Please input value 1 user enters 24
  • Please input value 2 user enters 12
  • Please input value 3 user enters 3
  • Please input value 4 user enters 45
  • Please input value 5 user enters 37
  • (List is created in ascending order
    3,12,24,37,45)

6
Example Usage of New Functions
  • List contains (3,12,24,37,45)
  • Delete_3(24)
  • List now contains (3,12)
Write a Comment
User Comments (0)
About PowerShow.com