Computer Science II - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Computer Science II

Description:

By the end of this course you should be able to ... Sorting: Quicksort; Mergesort, Radix Sort. Project 5. 13. 14. Hashing. 12. 15. Review for Final ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 21
Provided by: joe9
Category:

less

Transcript and Presenter's Notes

Title: Computer Science II


1
Computer Science II
  • Introduction Review

2
Computer Science II
  • Day/Time/Room MW/130-310 pm/WS 116
  • Text Data Structures Other Objects Using
    CMichael Main Walter SavitchAddison-Wesley,
    2005

3
Computer Science II
  • Instructor William J. Joel
  • Office WS 110
  • Office Hours Posted
  • Phone 7-9353
  • Email joelw_at_wcsu.edu
  • Website http//cs.wcsu.edu/joelw

4
Course Objectives
  • By the end of this course you should be able to
  • Discuss the design and implementation of classes
    in C, specifically for dynamic arrays, lists,
    trees and graphs.
  • State and describe basic algorithms for list,
    tree and graph, traversals and sorting.
  • Evaluate the performance of a given algorithm
    using Big-O notation.

5
Tests
  • Five (5), non-cumulative tests, approximately 1
    hour in duration
  • No mid-term exam
  • Cumulative final exam

6
Assignments
  • Five (5) programming projects.
  • No initial project submission will be accepted
    after its due date.
  • Students may may re-submit projects, with
    corrections, no later than 24 hours after initial
    return.
  • All re-submissions are due by the next project
    due date.

7
Attendence
  • You are expected to be present for each class
    session.
  • If you are absent, it is your responsibility to
    obtain class notes and handouts (if any) from
    your classmates I will not keep extra copies of
    materials after they are initially distributed
    most materials can be found on the courses
    website.
  • 24-hour notice must be given if you cannot make a
    scheduled test, otherwise you will receive a
    grade of 0 for the test.

8
Grading
  • Tests (lowest dropped) 40
  • Assignments 30
  • Final exam 20
  • Class participation 10
  • _______________________
  • Total 100

9
Tentative Topic Outline
10
Tentative Topic Outline
11
Tentative Topic Outline
12
Review
  • Personal Assessment Test
  • Test duration 30 minutes

13
Pointers
  • A pointer is an entity that
  • References another entity
  • Stores the value of an address (memory location)

101
45
14
Pointers
  • p is a pointer variable which stores the address
    of int variable x
  • p is a de-referenced pointer
  • x is the address of x

How do we do this?
15
Pointers
  • First, declare p as a pointer to a given datatype
  • myType p, x
  • Next, assign the address of a variable to p
  • p x

16
new Operator
  • The operator new is used to allocate memory
    storage dynamically
  • myType pp new myType
  • p now points to a nameless variable of type
    myType
  • All dynamically allocation occurs in that part of
    main memory called the heap

17
Problems
  • Given
  • int p, x
  • Determine the values of p and x be after
  • x 5p xp 10
  • How do pointers and call by reference relate to
    each other?

18
Dynamic Arrays
  • Space for an array can be dynamically allocated
  • Int myArray
  • myArray new int5
  • This creates an unnamed five element integer array

19
Dynamic Arrays
  • //
  • // This program demonstrates how to create a
    dynamic array
  • //
  • include ltiostream.hgt
  • void main()
  • int myArray, cnt, num
  • cout ltlt "Size "
  • cin gtgt num
  • cout ltlt endl
  • myArray new intnum
  • for(cnt0cntltnumcnt)
  • cout ltlt cnt ltlt " "
  • First, declare a pointer to the array
  • Then, allocate space for the array

20
Try this!
  • Create a class called vector that can
  • be indexed like an array
  • grow or shrink as needed
  • Questions
  • What data members and member functions will you
    require?
  • How do you overload the indexing operator?
  • How do you shrink/grow the data structure?
  • Work in teams, 3 students each
Write a Comment
User Comments (0)
About PowerShow.com