1. Trang chủ
  2. » Giáo Dục - Đào Tạo

ITC review 08

7 34 1

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 7
Dung lượng 419,86 KB

Nội dung

Connecting with Computer Science Chapter Review: Chapter Summary  Data Structures are used to organize data  Arrays are stored in continuous memory cells (one right after the other)  To define an array, you must specify the array: name, type and size  A single-dimensional array is a structure consisting of one level of array elements  A multiple-dimensional array is a structure consisting of more than one level, and each level consists of an array  The array's size is stored internally by using an upper and lower bound  A pointer is a memory variable that points to a memory cell location  A linked list is a data structure that can be used when the size of the information to be stored is unknown or will change Stacks and queues are forms of linked lists  A stack uses a last in, first out (LIFO) structure  A queue uses a first in, first out (FIFO) structure  A tree data structure represents a hierarchical storage method  Each position in a tree is called a node  Binary search trees are efficient for searching information  There is a wide variety of sorting algorithms, including: selection, bubble, quick-sort, merge, insertion and shell sorts Key Terms: Array: (280) Binary Search Tree: (301) Bubble Sort: (306) Data Structure: (279) Depth or Level: (300) Dequeue: (297) Element: (282) Enqueue: (298) First in First Out: (297) Head Pointer: (292) Height: (300) Index (Subscript): (284) Last in, First Out: (295) Leaf Node: (300) Left Child: (299) Linked List: (290) Lower Bound: (284) Multi-Dim Array: (285) Node (vertex): (299) Null Value: (292) Offset: (283) Peeking: (295) Pointer: (291) Pop: (295) Procedure: (296) Push: (295) Queue: (297) Recursion: (310) Right Child: (299) Root: (300) Selection Sort: (304) Stack: (294) Stack Pointer: (296) Tail Pointer: (297) Tree: (299) Upper Bound: (284) A set of contiguous memory cells used for storing the same type of data A binary tree in which the left child's data value is less than the parent node's, and the right child's data value is greater than the parent node's A sorting routine that compares each item in the list with the item next to it; if the first item is greater than the second it swaps them, and then repeats this process until it makes a pass all the way through the list without swapping any items A way of organizing data in memory, such as: arrays, lists, stacks queues and stacks The distance from the node to the root node The root's depth or level is To remove an item from a queue A memory cell in an array To insert an item into a queue The last item placed on the stack is the last item removed from the stack, and the first item removed from the stack is the first item placed onto the stack A pointer indicating the beginning of the first element in a data structure The longest path length in the tree How an array accesses each element stored in its data structure The last item placed on the stack is the first item removed from the stack A node that has no child nodes The child node to the left of the parent node A data structure that uses noncontiguous memory locations to store data; each element in the linked list points to the next element in line and does not have to be contiguous with the previous element The lowest position in an array An array consisting of two or more single dimensional arrays A position in a tree data structure The absence of a value, meaning there is no value stored; null is not the same as: blank or zero Used to specify the distance between memory locations Looking at the top item in the stack without removing it from the stack A memory variable containing the address of a memory cell as its data Remove an item from the stack A group of one or more related commands that perform a task Place an item on the stack A list in which the next item to be removed is the item that has been in the list the longest The process of a routine calling itself The child node to the right of the parent node The node that begins the tree A sorting routine that selects the smallest unsorted item remaining in the list and then swaps it with the item in the next position to be filled A list in which the next item to be removed is the item most recently stored A pointer that keeps track of where to remove or add an item in a data structure Keeps track of the end or rear position of the data structure A data structure that represents a hierarchical structure, similar to that of organizational genealogical charts The highest position in an array Test Yourself: 1.) Describe the uses of an array  Arrays are used for storing similar kinds of information in memory This information can be sorted or left in the order it was entered in the array Arrays can be used to store student grades, book titles, names of college courses, a space shuttle launch checklist, and so on 2.) How would you define an array to keep track of students' ID numbers (integer value) and their final grades, rounded to the nearest whole number (integer Value)?  int [ ][ ] aStudentId = new int [5] [5] ; 3.) Using the array defined in question #2 write the statement to store information for the five students' ID numbers and final averages in each array element  int aStudentId [ ] [ ] = { {32, 12, 18, 54, 22}, {10,11,12,13,14} } ; 4.) Describe in your own words how a stack works  Stacks are similar to an all-you-can-eat buffet Restaurants provide plates for customers The plate holder is spring loaded, and as the customer removes a plate from the stack, every plate moves up one position 5.) Describe in your own words how a queue works  Insertions are made at the end of the stack and deletions are made at the beginning Similar to waiting for a ride at an amusement park The first person in line is the first person to get on the ride and leave the line, whereas the last person in line waits the longest to get on the ride and leave the line 6.) Describe in your own words how a binary tree works  A binary tree is like a family tree It represents data in an orderly fashion and is useful for list-like data speeding up searches 7.) Show each step to sort the data by using a bubble sort [Use Fig 8-34] 5 32 10 25 32 10 25 5 32 10 25 32 10 25 5 32 10 25 32 10 25 5 32 10 25 32 10 25 5 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 32 10 25 10 32 25 10 32 25 10 32 25 10 32 25 10 25 32 8.) Show each step to sort the data by using a selection sort [Use Fig 8-34] 32 25 10 10 25 32 9.) Show each step to sort the data by using a bubble sort [Use Fig 8-35] 5 32 30 20 5 32 30 20 5 32 30 20 5 32 30 20 5 32 30 20 5 32 30 20 5 32 30 20 5 20 32 30 5 20 32 30 5 20 30 32 5 32 30 20 5 32 20 30 5 20 32 30 5 20 30 32 10.) Show each step to sort the data by using a selection sort [Use Fig 8-35] 32 30 20 30 32 20 5 30 32 20 5 20 32 30 11.) Label the root and leaf nodes [Use Fig 8-36] 12.) What the maximum height of the tree?  The height of the tree is: 13.) On what level is the node with the value 15? [Use Fig 8-36]  The node with the value 15 is on level 14.) Show the steps to find the value [Use Fig 8-36]     Start at the root node Does the value = the root value (21)? No Then is the value > the root value (21) No Move left child (19) Does the value = the root value (19)? No Then is the value > the root value (19) No Move left child (10) Does the value = the root value (10)? No Then is the value > the root value (10) No Move left child (7)  Does the value = the root value (10)? Yes Stop traversing the tree 15.) Show the steps to find the value 17 [Use Fig 8-36]  Start at the root node  Does the value 17 = the root node 21? No Then is the value 17 > the root value (21)? No Move left child (19)  Does the value 17 = the root value 19? No Then is the value 17 > the root value (19)? No Move left child (10)  Does the value 17 = the root value 10? No Then is the value 17 > the root value (10)? Yes Move right Child (15)  Does the value 17 = the root value 15? No Then is the value 17 > the root value (15)? Yes Move right Child (17)  Does the value 17 = the root value 17? Yes Stop traversing the tree Practice Exercises: 1.) A (n) array is a data structure consisting of contiguous memory locations 2.) A(n) index is used is access each element 3.) A single array can contain information of different types of data (integers, characters, decimals, and so on) FALSE 4.) The statement char[ ] aAnswers = new char[5] declares an array that has memory locations of through FALSE 5.) The offset is used to specify the distance between memory locations TRUE 6.) Arrays are a good data structure to use with dynamic data TRUE 7.) A stack uses a LIFO structure TRUE 8.) A queue uses a FIFO structure TRUE 9.) LIFO is an acronym for: Last In First Out 10.) FIFO is an acronym for: First In First Out Use Figure 8-37 to answer questions 11 - 15 11.) How many comparisons does it take to find the following numbers? [RESEARCH MORE] a  b  c 23  d 30  e 17  12.) What is the number of nodes on level 3? 13.) What is the number of nodes on level 4? 14.) What is the maximum height of the tree? 15.) How many right and left child nodes are there?  Right:  Left: Given the following numbers: 1, 2, 3, 4, 6, 7, 8, 9, 10,11 and 12 answer questions 16 through 20 16.) Draw a binary tree from these numbers Make sure binary tree rules are applied

Ngày đăng: 27/10/2019, 23:07

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...

TÀI LIỆU LIÊN QUAN