question 1you are required to provide suitable


QUESTION 1

You are required to provide suitable examples of your own for each part of the question where appropriate

(a)(i) Define a structure?

(ii) What is a structure member?

(iii) How can structure variables be declared?

(iv) How can the members of a structure variable be assigned initial values?

(v) How can the size of a structure be determined?

(b)(i) What is a union?

(ii) How does a union differ from a structure?

(iii) How is a union member accessed?

(iv) How can a member of a union variable be assigned an initial value?

(v) Explain the rules which apply when processing unions

(c) Write down a structure which contains the following four members-

(i) an integer quantity called student_id

(ii) a 40-element character array called student_name

(iii) an integer quantity called phone_number

(iv) a floating-point quantity called marks

Include the user defined data type 'student' within the definition

QUESTION 2

(a)(i) What is the primary advantage when using data files in programs?

(ii) Describe how data files can be categorized in C

(iii) What is the purpose of a buffer area when working with data files?

(iv) Explain how the buffer area is defined?

(b)(i) What is a stream pointer?

(ii) What is the relationship between a stream pointer and a buffer area?

(iii) Explain the process of opening a data file in C

(c) Read the sample C program given below and answer the questions based on it

#include

main( ){

FILE *opt1, *opt2; char student_name[30];

opt1 = fopen("list.old", "r");

opt2 = fopen("list.new", "w")

......................

fclose(opt1);

fclose(opt2);

}

Write down appropriate statements to perform the following tasks-

(i) Read the string represented by student_name from the file list.old

(ii) Display the result on the screen

(iii) Enter an updated string

(iv) Write the new string to the data file list.new

QUESTION 3

(a) Give two advantages of using 'Linked List' instead of 'arrays' in programs

(b) Write down the definition of a 'linked list' to contain the following-

(i) course_id of datatype integer

(ii) character array course_name of size 40

(iii) floating-point variables duration and fees

(iv) pointer variable next of the same structure type

(v) Include the tag course within the definition

(c)(i) Declare two variables of type course

(ii) Write down appropriate statement(s) to allocate memory to the first node

(d) Write down the function to create the linked list with the nodes declared. This function must also allow the user to terminate the input

QUESTION 4

(a) Explain the following sorting techniques using appropriate algorithms-

(i) selection sort

(ii) bubble sort

(b) Explain how 'linear search' differs from 'binary search' using suitable algorithms

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: question 1you are required to provide suitable
Reference No:- TGS0445208

Expected delivery within 24 Hours