Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Data Structure Expert

QUESTION 1

(a) (i) What is a pointer? Illustrate with an example

(ii) Give two advantages of the use of pointers over arrays

(b) (i) Declare an array called vowel which contains the elements ‘a', ‘e', ‘i', ‘o', and ‘u'. (ii) Declare a pointer ptr of type char which points to the array vowel

(iii) Write down a loop to display the actual address and content of pointer ptr when it points to the different elements of array vowel

(c) (i) Declare an integer array of size ten

(ii) Write down appropriate statements to request the user to enter ten integer numbers into the array created in c (i) above

(iii) Write down appropriate statements which will search the number zero inside the array using linear search algorithm. Include an output statement to print out the number of elements in the array before the zero if it is found

QUESTION 2

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

(ii) How can the size of a structure be determined? In what units is the size reported?

(iii) How is a structure-type pointer variable declared? To what does this type of variable point?

(b) What is a self-referential structure? Illustrate with a suitable example

(c) (i) Define a structure that contains the following members: 1) dvd_name, 2) quantity and 3) cost Include a user-defined data-type movie within the definition

(ii) Now define another structure that contains the following members: 1) batch_id and 2) film of type movie defined above Include the user-defined data type dvd within the definition

(iii) Declare a variable v1 to be a structure variable of type dvd. Write an expression for each member and submember of v1

(iv) Declare a variable v2 to be a structure variable of type dvd and initialize v2 with the following values: dvd_name: Red Dragon quantity: 4 cost: 100 batch_id: 2101

(d) (i) What is the primary advantage to using a data file?

(ii) Describe the different ways in which a data file can be categorized

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

(iv) How is the buffer area defined?

(v) What is meant by opening a data file?

QUESTION 3

(a) Using an appropriate example, explain what is a recursive function?

(b) Write a small program using a function called cumulative that accepts as parameter n and returns the sum of integers between 1 and n inclusive

(c) A student was asked to write a program in C to swap two numbers using a function and pointers. However the student failed to solve the work and the program was left incomplete as shown below. Use the code extract below to complete the program using function and pointers

#include

void swap(int *, int *);

void main { int a = 23, b = 32; ... ... }

void swap(int *x, int *y) { int temp; .... ..... }

QUESTION 4

(a) Write down the sample code to create a 'Linked List' and allocate storage space for a node

(b) Write down the algorithm to insert an item

(i) At the beginning of a linked list

(ii) In the middle of a linked list

(iii) At the end of a linked list

(c) Write down the sample code to declare a stack

(d) Explain how the binary tree below can be traversed in each of the following ways-

(i) preorder

(ii) inorder

(iii) postorder

361_binary tree.png

Data Structure, Computer Science

  • Category:- Data Structure
  • Reference No.:- M9719320

Have any Question?


Related Questions in Data Structure

Problem regarding the management program

Problem: Looks like its just adding a save and load feature to the same file you sent me for python 3.5 Until now, you have had to leave your team management program running on your computer indefinitely since you did no ...

Data Communication Delivering Information anywhere

Topic: Data Communication Delivering Information anywhere. Write a 9-12 pages paper in which you: Present an overview of the origin and history of the concept. Describe the current use of and attitude toward the concept. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As