Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Software Development and Computer Networking Exam - Computer Programming II (Autumn 2005), Exams of Computer Engineering and Programming

Instructions and questions for an exam in computer programming ii, which is part of a bachelor of science (honours) in software development and computer networking degree at cork institute of technology. The exam covers topics such as setting up data structures, linear queues, node representation, sorting algorithms, processes, ipc, threads, semaphores, and sockets.

Typology: Exams

2012/2013

Uploaded on 03/28/2013

duraid
duraid 🇮🇳

4.3

(3)

75 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Bachelor of Science (Honours) in Software Development and Computer Networking - Stage 2
(Bachelor of Science in Software Development and Computer Networking - Stage 2)
(NFQ – Level 8)
Autumn 2005
Computer Programming II
(Time: 3 Hours)
Instructions
Answer question 1 and any three others
Q1 carries 30 marks, Q2 and Q3 carry 20 marks
each; Q4, 5,6 carry 25 marks each.
Answer Section A and Section B in separate
answer books.
Examiners: Dr. D. Chambers
Mr. T. Parslow
Mr. P. O’Connor
Ms. G. MacSweeney
Mr. J. O’Dwyer
Section A
Q1. (compulsory)
Bank Account Details
A bank stores details for 500 customers.
Each customer may hold up to 1000 transactions
(a) (i) Set up date details unit which holds the following
day
month
year (1 mark)
(ii) Set up the transaction unit which holds the following
date
description
amount
deposit Or withdrawal Indicatior
outgoing balance (2 marks)
(iii) Set up the customer details to store the following
Name
Address
Balance
All Transactions
Ongoing Transaction Number (2marks)
Part A
Î
5 marks
(b) (i) Write the code to set up a linear queue to handle 10 customers at a time
emulating customers arriving at a counter in a Bank
pf3
pf4
pf5

Partial preview of the text

Download Software Development and Computer Networking Exam - Computer Programming II (Autumn 2005) and more Exams Computer Engineering and Programming in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Science (Honours) in Software Development and Computer Networking - Stage 2 (Bachelor of Science in Software Development and Computer Networking - Stage 2) (NFQ – Level 8)

Autumn 2005

Computer Programming II

(Time: 3 Hours)

InstructionsAnswer question 1 and any three others Q1 carries 30 marks, Q2 and Q3 carry 20 markseach; Q4, 5,6 carry 25 marks each. Answer Section A and Section B in separateanswer books.

Examiners: Dr. D. ChambersMr. T. Parslow Mr. P. O’ConnorMs. G. MacSweeney Mr. J. O’Dwyer

Section A

Q1. (compulsory) Bank Account Details A bank stores details for 500 customers. Each customer may hold up to 1000 transactions (a) (i) Set up date details unit which holds the following day month year (1 mark) (ii) Set up the transaction unit which holds the following date description amount deposit Or withdrawal Indicatior outgoing balance (2 marks) (iii) Set up the customer details to store the following Name Address Balance All Transactions Ongoing Transaction Number (2marks) Part A Î 5 marks (b) (i) Write the code to set up a linear queue to handle 10 customers at a time emulating customers arriving at a counter in a Bank

(3 marks) (ii) Write the code to insert a customer into a linear queue. On inserting a customer successfully, return 1 otherwise 0 (4 marks) (iii) Write the code to check if the queue is empty, if so return 1 otherwise return 0. (2 marks) Part B Î 9 marks

(c) Main Program (i) Set up an array of customers representing 500 in total representing all the bank customers (1 mark) (ii) Create a new customer with full details and add it to the customer array. Remember you are entering one customer at a time (3 marks) (iii) On entering the bank, assume there is an empty linear queue which has the customers served in turn as they join the end of the queue.

  • Ask for the customer Account number & Check that the customer is present in the customer array
  • Copy the customer from the customer array and insert into the linear queue
  • On arrival at the counter, remove from the queue
  • Make a transaction for making a deposit 30 euro.
  • Ensure that you add the date, description, deposit amount and update the balance using the balance from the customer.
  • Note if a deposit, set the deposit indicator to 1 otherwise 0;
  • Add the transaction to the customer’s set of transaction
  • Update the customer’s overall balance (12 marks) Part C Î 17 marks Question 1 ==Î 30 marks

Set smallest = x[ SmallPos ] For j=I +1 to n- if x[j] < smallest Set SmallPos = j; Set smallest = x [SmallPos ] Set x[SmallPos ] = x[I ] Set x[i] = smallest

(i) Y ou are required to display each step involved in making 2 passes through the algorithm 45, 26, 56, 78, 23 (10 marks) (ii) Explain in English how this algorithm works (5 marks) (iii) Compare the above sort routine with the bubbler sort (5 marks)

Question 3 Î 20 marks

Section B

Q4. (a) What is a process? Outline two methods by which processes may be created. Compare and contrast the two approaches. Using C type syntax, write a program that will activate the Unix commands ls, who or exit() using a menu-based selection (9 marks) (b) What is IPC? In a UNIX environment, pipes are a well known IPC mechanism. Describe pipes giving their advantages and disadvantages as an IPC mechanism. (6 marks) (c) You are required to set up a system which will allow a user to input a series of character strings in random order and output them in sorted (alphabetic) order. The input process must check that each string is alphabetic before it passes the string to the system SORT routine. A string beginning with XXX marks the end of input. SORT must pass the sorted data to an output process that will print the strings two across the screen. When the end of output is detected the output process will print a count of the number of strings output. Write the code to solve the above problem using C/C type pseudocode. The solution should have three processes that communicate via pipes. (useful C functions are fork(), dup2(), execlp(), sort(), isalpha() ) (10 marks) Q5. (a) What is a thread? Contrast threads and processes. Distinguish between multiplexed threads and bound threads. Draw a state transition for a multiplexed thread. (8 marks)

(b) Outline the steps needed to set-up a client–server application using connection–oriented sockets. A consultancy company wishes to set up a simple system that will allow the company to know when a member is in the building. The system will have a central repository

of names. For each member there will be a name, e-mail address, office, tel-no and status(in/out). When a member enters his/her office, the member starts the client programme that will change the status to in on the central server. The reverse process operates on leaving. The server also notes the entry and exit times and records these in a file with the same name as the member. The file record contains date, time-in and exit-time. The receptionist or any other member can query the repository on any member’s status. The secretary adds new members and updates details on existing members. The repository must allow multiple concurrent users. What synchronisation problem, if any, needs to be addressed in the application? Which synchronisation primitives should be used in this application and why? Assume the application is to be constructed using connection oriented sockets. Sketch the server side solution to the problem using C/C type pseudocode. Your answer should highlight thread and synchronisation level details. (12 marks) (c) Advances in networking technology have made sockets unnecessary. Discuss: (5 marks)