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[4] = {"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?

(iii) State one disadvantage of using linked list in structured programs

(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

Reference no: EM133645

Questions Cloud

Prepare journal entries for mcdaniel : Prepare journal entries on 1/1/2015 for McDaniel Prepare journal entries on 12/31/2015 for McDaniel
Explain the sorting techniques selection sort : Explain the following sorting techniques using appropriate algorithms- (i) selection sort (ii) bubble sort
How long can craft hover over the moon surface : How long can craft hover over the moon surface Contract between Einstein's calculations and observed precession
What are the corresponding velocity vectors : What are the corresponding velocity vectors
Explain the fifo structure of the queue : Explain the FIFO structure of the queue Explain how you would implement the queue data structure in its simplest form. Illustrate your answer fully with the necessary sample code
Find out the minimum sound intensity : Find out  the minimum sound intensity
What is ratio of the applied force : What is ratio of the applied force
Find out the minimum horizontal velocity : Find out the minimum horizontal velocity magnitude of the acceleration of the blocks
How the system comes to thermal equilibrium : How  the system comes  to thermal equilibrium

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Data structures and algorithm design

Data Structures and Algorithm Design

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Data structures and algorithms

Provides learners with an understanding of how data structures are used in algorithms and enables them to design and implement data structures

  Write the selection sort algorithm

Write the selection sort algorithm

  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

  Data structures and algorithm design

Data Structures and Algorithm Design

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Write a c++ program to find the intersection

Write a C++ program to find the intersection, A set is a collection of distinct entities regarded as a unit, being either individually specified or (more usually) satisfying specified conditions.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd