BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security. & BSc. (Hons.) Software Engineering

Similar documents
Level 3 Develop software using Java (7266/ )

Illustration 1: Diagram of program function and data flow

LINKED DATA STRUCTURES

10CS35: Data Structures Using C

Quiz 4 Solutions EECS 211: FUNDAMENTALS OF COMPUTER PROGRAMMING II. 1 Q u i z 4 S o l u t i o n s

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

This lecture. Abstract data types Stacks Queues. ADTs, Stacks, Queues Goodrich, Tamassia

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

Lecture 12 Doubly Linked Lists (with Recursion)

Linked Lists Linked Lists, Queues, and Stacks

DATA STRUCTURES USING C

Linked Lists, Stacks, Queues, Deques. It s time for a chainge!

Algorithms and Data Structures Written Exam Proposed SOLUTION

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

COMPUTER SCIENCE. Paper 1 (THEORY)

Introduction to Python

A binary search tree or BST is a binary tree that is either empty or in which the data element of each node has a key, and:

BSc (Hons) Banking and International Finance Cohort: BBIF/07/FT Year 1. BSc (Hons) Banking and International Finance Cohort: BBIF/07/PT Year 1

Questions 1 through 25 are worth 2 points each. Choose one best answer for each.

CmpSci 187: Programming with Data Structures Spring 2015

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

Binary Heaps * * * * * * * / / \ / \ / \ / \ / \ * * * * * * * * * * * / / \ / \ / / \ / \ * * * * * * * * * *

Data Structures. Level 6 C Module Descriptor

Object Oriented Software Design II

Queues Outline and Required Reading: Queues ( 4.2 except 4.2.4) COSC 2011, Fall 2003, Section A Instructor: N. Vlajic

The Elective Part of the NSS ICT Curriculum D. Software Development

QUEUES. Primitive Queue operations. enqueue (q, x): inserts item x at the rear of the queue q

Data Structures Using C++ 2E. Chapter 5 Linked Lists

Data Structures Using C++ 2E. Chapter 5 Linked Lists

MAX = 5 Current = 0 'This will declare an array with 5 elements. Inserting a Value onto the Stack (Push)

1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2)

Lecture 11 Doubly Linked Lists & Array of Linked Lists. Doubly Linked Lists

Cours de C++ Utilisations des conteneurs

Queues. Manolis Koubarakis. Data Structures and Programming Techniques

BSc (Hons) Sofware Engineering. Examinations for / Semester 2

PES Institute of Technology-BSC QUESTION BANK

Analysis of a Search Algorithm

Module 816. File Management in C. M. Campbell 1993 Deakin University

API for java.util.iterator. ! hasnext() Are there more items in the list? ! next() Return the next item in the list.

Jorix kernel: real-time scheduling

IPC. Semaphores were chosen for synchronisation (out of several options).

ADTs,, Arrays, Linked Lists

Stacks. Linear data structures

DATA STRUCTURE - QUEUE

Common Data Structures

Molecular Dynamics Simulations with Applications in Soft Matter Handout 7 Memory Diagram of a Struct

Chapter 3: Restricted Structures Page 1

1. The memory address of the first element of an array is called A. floor address B. foundation addressc. first address D.

Data Structures and Data Manipulation

Data Structures and Algorithms

1 External Model Access

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

Project 4 DB A Simple database program

Stacks. Stacks (and Queues) Stacks. q Stack: what is it? q ADT. q Applications. q Implementation(s) CSCU9A3 1

GUJARAT TECHNOLOGICAL UNIVERSITY, AHMEDABAD, GUJARAT COURSE CURRICULUM. Course Title: Advanced Computer Programming (Code: )

Why Use Binary Trees?

COMPUTER SCIENCE 1999 (Delhi Board)

Masters programmes in Computer Science and Information Systems. Object-Oriented Design and Programming. Sample module entry test xxth December 2013

St S a t ck a ck nd Qu Q eue 1

Unordered Linked Lists

Pointers and Linked Lists

Introduction to Data Structures

Lecture Notes on Binary Search Trees

Binary Heap Algorithms

ECE 250 Data Structures and Algorithms MIDTERM EXAMINATION /5:15-6:45 REC-200, EVI-350, RCH-106, HH-139

Data Structures Using C++

Algorithms and Data Structures Exercise for the Final Exam (17 June 2014) Stack, Queue, Lists, Trees, Heap

Tutorial on C Language Programming

Queue ADT. March 16, 2000

The following themes form the major topics of this chapter: The terms and concepts related to trees (Section 5.2).

Analysis of Binary Search algorithm and Selection Sort algorithm

Data Types. Abstract Data Types. ADTs as Design Tool. Abstract Data Types. Integer ADT. Principle of Abstraction

root node level: internal node edge leaf node Data Structures & Algorithms McQuain

recursion, O(n), linked lists 6/14

8 9 +

USER GUIDE Appointment Manager

Course MS10975A Introduction to Programming. Length: 5 Days

C++ DATA STRUCTURES. Defining a Structure: Accessing Structure Members:

7.1 Our Current Model

SSC - Concurrency and Multi-threading Java multithreading programming - Synchronisation (I)

C++ Programming Language

The C Programming Language course syllabus associate level

Object Oriented Software Design II

INTERNATIONAL JOURNAL OF PURE AND APPLIED RESEARCH IN ENGINEERING AND TECHNOLOGY

Basic Data Structures and Algorithms

DATA STRUCTURE - STACK

What is COM/DCOM. Distributed Object Systems 4 COM/DCOM. COM vs Corba 1. COM vs. Corba 2. Multiple inheritance vs multiple interfaces

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Threads Scheduling on Linux Operating Systems

Ordered Lists and Binary Trees

STACKS,QUEUES, AND LINKED LISTS

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

Chapter 8: Bags and Sets

Data Structures and Algorithms

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Bachelor of Games and Virtual Worlds (Programming) Subject and Course Summaries

On the (un)suitability of Java to be the first programming language

CSE 211: Data Structures Lecture Notes VII

Transcription:

BSc (Hons) Business Information Systems, BSc (Hons) Computer Science with Network Security & BSc. (Hons.) Software Engineering Cohort: BIS/05/FT BCNS/05/FT BSE/05/FT Examinations for 2005-2006 / Semester 2 MODULE: STRUCTURED PROGRAMMING MODULE CODE: PRG103 Duration: 2 Hours and 15 Minutes Instructions to Candidates: 1. Answer all questions. 2. Programs can be written in C or C++ language. 3. Questions may be answered in any order but your answers must show the question number clearly. 4. Always start a new question on a fresh page. 5. All questions carry equal marks. 6. Total marks 100. This question paper contains 4 questions and 6 pages. Page 1 of 6

QUESTION 1: (25 MARKS) ANSWER ALL QUESTIONS (a) Given a function prototype as shown below. void swap(int *, int *); Write a C/C++ program to pass two variable pointers to that function to swap two integer numbers. (7 marks) (b) Write a C/C++ function that receives two integer parameters and returns an integer. The value returned should be 0 if the parameter values are the same, -1 if the first value is less than the second and 1 if the second value is greater than the first. (5 marks) (c) The following explains how the computation of commission is performed in a company. (i) The price of one book is Rs.200. (iii) Salesmen receive a commission of 20% on each book they sell. Salesmen receiving more than Rs.400 commission receive a bonus of Rs.100. Write a function calculate that will take as parameter the number of books sold by a salesman and will return the commission to be received by the salesman. (13 marks) Page 2 of 6

QUESTION 2: (25 MARKS) (a) Describe the two C functions fprintf() and fscanf(). Using appropriate examples, write the full syntax for each function. (b) Write a C/C++ program that will perform the following: (i) Accept as input 3 book titles and 3 book prices Write the input data into a text file (book.txt) (12 marks) (c) The file info.txt contains information such as name of students and their corresponding ages (see preview below). Write a C/C++ program that will allow a user to read the first student s details. The output should be as shown below. (12 marks) Page 3 of 6

QUESTION 3: (25 MARKS) (a) What is a queue? List two applications of a queue. (4 marks) (b) Give two examples of the use of queues in the real world. (1 mark) (c) What is a Priority queue? (2 marks) (d) Given the following structures and type definition: struct que { int item; struct que *next; } ; struct queu { struct que *front, *rear; }; typedef struct queu queueq; Using C/C++ write functions for the following operations. (i) empty - has one argument of type pointer to queueq, checks if the queue is empty and returns a boolean or integer value. initialise - has one argument of type pointer to queueq, initialises the queue to null and the return type is void. (iii) insert has two argument, one of type pointer to queueq, insert the integer at the rear of the queue and the second of type integer and the return type is void. (Continued) Page 4 of 6

Question 3 : (continued) (iv) remove has one argument of type pointer to queueq, deletes the item at the front and the return type is an integer. (e) Suppose you have an empty linked list (i.e. pointing to NULL) and the following statements are executed: additem(25); additem(50); additem(60); Draw the resulting linked list if the list was implemented using (i) a stack a queue. (Please turn over) Page 5 of 6

QUESTION 4: (25 MARKS) (a) Describe a linked list. (b) Explain the three different types of linked list with the help of diagrams. (c) Give two advantages and two disadvantages of pointer based implementation of a list over array based implementation? (4 marks) (d) Explain how the following operations are performed in a single linked list. You should explain the algorithms using diagrams. (i) Insert a new node at the front of the list. Delete a node located between two nodes of the list. ***END OF QUESTION PAPER*** Page 6 of 6