### Explain the fifo structure of the queue

Assignment Help Data Structure & Algorithms
##### Reference no: EM133645

Question 1

(a) Explain the meaning of each of the following pointer declarations:-

(i) float a = -0.137;

float *pa = &a;

(ii) double *fa(double *a, double *b, double *c);

(iii) char *d = {"north", "south", "east", "west"};

(iv) int (*pf)(char *a, char *b);

(b) Read the structured program below and answer the questions based on it

int i, j = 25;

int *pi, *pj = &j;

*pj = j + 5;

i = *pj + 5;

pi = pj;

*pi = i + j;

Assume each integer quantity occupies 2 bytes of memory, the hexadecimal address of i begins at F9E and that of j at FA0

(i) What value is represented by &i?

(ii) What value is represented by &j?

(iii) What value is assigned to pj?

(iv) What value is assigned to *pj?

(v) What value is assigned to i?

(vi) What value is represented by pi?

(vii) What final value is assigned to *pi?

(viii) What value is represented by (pi + 2)?

(ix) What value is represented by the expression (*pi + 2)?

(x) What value is represented by the expression *(pi + 2)?

(c) Write an appropriate declaration for each of the following situations involving pointers

(i) Declare a function that accepts an argument which is a pointer to an integer quantity and returns a pointer to a six-element character array

(ii) Declare a function that accepts an argument which is a pointer to an integer array and returns a character

(iii) Declare a function that accepts an argument which is an array of pointers to integer quantities and returns a character

(iv) Declare a function that accepts an argument which is an integer array and returns a pointer to a character

(d)(i) What is the purpose of the buffer area when working with a stream oriented data file?

(ii) How is the buffer area defined? Illustrate your answer with the appropriate sample code

(iii) What is the purpose of the fclose function? Is it necessary within a program using a data file?

(e) Write the sample code to open a data file called 'inputfile.txt' in read only mode and to check whether the file is correctly opened

Question 2

(a) How does a structure differ from an array? Illustrate your answer with simple examples

(b) Explain how a structure differs from a union? Illustrate your answer with simple examples

(c) Write the sample code to declare a union named 'clothes'. The union has two variables 'shirt' and 'blouse' and its members are-

1. manufacturer of type character and size 20

2. cost of type float

3. size of type character (e.g:- S - small, M - medium, L - large and XLextra large)

(d) Explain what is a 'nested structure'. Illustrate your answer with a suitable example

(e) (i) Define a structure consisting of two floating point members called real and imaginary. Include a tag called complex within the definition

(ii) Declare three variables x1, x2 and x3 of be structures of type complex

(iii) Assign the initial values of 1.3 and -2.2 to the members x.real and x.imaginary, respectively

(iv) Declare a pointer variable px to point to a structure of type complex

(v) Declare a one-dimensional 100-element array called cx whose elements are structures of type complex

(vi) Combine the structure definition and the array declaration of part (v) into one single declaration

(f) (i) Define a union called 'dateTime' which contains three members: hour, minute and second

(ii) Define a structure called 'calendarDate' which contains three integers members: day, month and year and a member time1 of type dateTime

(iii) Declare a variable date1 of type 'calendarDate'

(iv) Set the time of date1 to: 10:30:25

Question 3

(a)

(i) What is recursion?

(ii) What advantage is there in its use?

(iii) What disadvantage is there in its use?

(b) The factorial of a positive number can be computed using the formula

n ! = 1 x 2 x 3 x..........x n

However, the function „factorial? can also be defined as a recursive function in programming exercises

Write down the main part of the program which contains the following-

(i) the function prototype

(ii) a positive integer variable n

(iii) an output statement to display n

(iv) an input statement to allow a user to enter a number (which is stored in variable n)

(v) another output statement that calculates and displays the factorial of the number

(vi) write down the function using recursion

(c) (i) Explain why a linked list is called a dynamic data structure?

(ii) What are the three most important advantages of using linked list over arrays?

(d) A stack is also a dynamic data structure which can be implemented in its simplest way by making use of arrays

Declare a structure containing:-

(i) an integer array to hold the elements of the stack

(ii) an integer to indicate the position of the current stack top within the array. Now write the „pop? operation to remove the top element from the stack. Write the "push? operation to add an element to the stack

Question 4

(a) One of the most common sorting techniques we have in programming is the "Bubble Sort?. This technique can be used to sort an array of elements in ascending order

Write down the sample code which will rearrange a list of numbers stored in an array in ascending order using the Bubble Sort

(b) (i) What do you understand by „linear search?? Illustrate with a simple algorithm of your own

(ii) Explain how the „binary search? differs from the „linear search?? Use a simple algorithm of the binary search to illustrate your answer

(c) (i) Explain the FIFO structure of the queue

(ii) Explain how you would implement the queue data structure in its simplest form. Illustrate your answer fully with the necessary sample code

### Write a Review

#### Survey of fault tolerance policy for load balancing scheme o

This paper investigates about fault-tolerance in load balancing schemes in distributed environment. There are some more parameters influencing QOS but our main focus is on fault tolerance and load balancing.

#### Different applications of data structure

What are the different applications of Data Structure

#### Currency conversion development

Currency Conversion Development

#### Use a search tree to find the solution

Explain how will use a search tree to find the solution.

#### Online vs. face-to-face classes

Communication A significant distinction between online and face-to-face classes lies in the area of communication.

#### Determine the inorder, preorder and postorder traversal

Determine the Inorder, preorder and postorder traversal

#### Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

#### Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

#### Data structures and algorithm design

Data Structures and Algorithm Design

#### Addition and subtraction of numbers in binary

Addition and Subtraction of numbers in binary and round to the nearest decimal number with three significant decimal digits

#### Data structures and algorithm design

Data Structures and Algorithm Design

#### C++ program to evaluate expressions combining set union

Create a C++ program to evaluate expressions combining set union, set intersection and parentheses 