Data structures; arrays By ZAK

50 %
50 %
Information about Data structures; arrays By ZAK

Published on September 29, 2015

Author: 34GL3

Source: slideshare.net

1. Page 1 of 3 2.2 Programming 2.2.2 Data structures; arrays Define and use arrays (one- and two-dimensional) for solving simple problems (this should include initializing arrays, reading data into arrays and performing a simple serial search on a one-dimensional array) A data structure is a collection of different data items that are stored together in a clearly defined way. Two common data structures are arrays and records. Array An array is a data structure, which allows a set of items of identical data type to be stored together using the same identifier name. Arrays are declared in a similar way to standard variables, except that the array size and dimensions are included. For example, the following declares an array that reserves five locations in memory and labels these as ‘Names’: DIM Names(4) As String The five individual locations are Names(0), Names(1), Names(2), Names(3), Names(4). Each data item is called an element of the array. To reference a particular element a programmer must use the appropriate index. For example, the following statement assigns data to the 5th element: Names(4) = “John” Arrays simplify the processing of similar data. An algorithm for getting five names from the user and storing them in the array Names is shown below: Dim Names(4) As String Dim name As String For i=0 to 4 Input name Names(i)=name Next i

2. Page 2 of 3 2.2 Programming 2.2.2 Data structures; arrays One-dimensional arrays A one-dimensional array is a data structure in which the array is declared using a single index and can be visually represented as a list. The following diagram shows the visual representation of the array Names(4):

3. Page 3 of 3 2.2 Programming 2.2.2 Data structures; arrays Array Questions: Question 01: Input and store the names and marks for 30 students who have sat three computer science tests. Test 1 is out of 20 marks, Test 2 is out of 25 marks, Test 3 is out of 35 marks. You must store the names in a one-dimensional array and the marks and total score for each student in one-dimensional arrays. All the marks must be validated on entry and any invalid marks rejected. You may assume that the students’ names are unique. Question 02: Calculate and store the total score for each student and calculate the average score for the whole class. Output each student’s name followed by their total score, and then output the average score for the class. Question 03: Select the student with the highest score and output their name and score. Your program must include appropriate prompts for the entry of data. Error messages and other output need to be set out clearly and understandably. All variables, constants and other identifiers must have meaningful names. Each task must be fully tested. Question 04: Write a pseudocode using array, asks user to input 10 numbers, then calculates the average of those numbers. Loop is used in this problem. Question 05: Write a pseudocode to swap first and last element of an integer 1-d array. Question 06: Write a pseudocode to find the largest and smallest element of an array.

Add a comment

Related pages

2.2.2 Data structures; arrays.pdf - Google Drive

Loading… Main menu
Read more

Data structures and arrays | BSSBMI

Data structures and arrays; Programming concepts; ... A. declare the size of one-dimensional arrays, ... ZAK Notes; Computer Systems ...
Read more

Extensive Examination of Data Structures Using C#

An Extensive Examination of Data Structures Using ... as do Fred, Zak, and Amy ... binary search trees are an ideal choice over arrays if you know you ...
Read more

example of linear and non-linear data structures?

example of linear and non-linear data structures? ALLInterview.com. ... Question Posted / zak_pure. 7 Answers ; ... Ex. Arrays, Stacks, Queues ...
Read more

Data Structure - scribd.com

Data Structures. Browse Browse. Interests. Biography & Memoir; Business & Leadership; Fiction & Literature; Politics & Economy; Health & Wellness; Society ...
Read more

DATA STRUCTURE IN C INDEX | C/C++ LEARNING

Archive for the ‘DATA STRUCTURE IN C INDEX ... Different kinds of data structures are suited to different kinds ... Arrays may be fixed-length ...
Read more

Elementary data types - ibm.com

The data types used in the MQI (or in exit functions) are either: Elementary data types, or; Aggregates of elementary data types (arrays or structures)
Read more

UCBerkeley - YouTube

... Data Structures ... trees, and other linked structures; arrays strings, and hash tables. ... UCBerkeley. 416,200 views; 8 years ago; 50:21.
Read more