Question

Question 7 Digital photo-frames contain a collection of photographs. These can be displayed in the order they were added to t

This is a question related to C

can you teach me how to do whole part dii?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

a. The underlying data structure should be Array. the reasons are as follows :

  1. contains a collection of similar type data elements whereas the Linked list is considered as non-primitive data elements.
  2. Arrays are of fixed size. while, Linked lists are dynamic and flexible also can be expanded and contracted its size. As mentioned the size of the photo frame is limited which confirms that the data structure should be array.

b. The abstract data type which suits to model the photo-frame should be set

  • the set has key and value structure, also the key is unique.
  • As per the photo-frame, key would be the date-time stamp and value would be the list of photos

c. the definition for photo_int and photo pointer are as follows :

// defining the pointer

int *photo;

// Pointer to an array of 5 photos which is photo_int and it is  

int (*photo_int)[5];

d. the model of photo-frame is

int main () {

   int photo_frame_int[ 10 ]; /* photo frame which can store 10 integers */
   int i,j;
 
   /* initialize elements of array n to 0 */         
   for ( i = 0; i < 10; i++ ) {
      photo_frame_int[ i ] = i + 100; /* set element at location i to i + 100 */
   }
   
   /* output each array element's value */
   for (j = 0; j < 10; j++ ) {
      printf("photos[%d] = %d\n", j, photo_frame_int[j] );
   }
 
   return 0;
}

ii)

  • An empty array capable of storing photos with capacity :
void init_photo_frame(photo_frame *fp, int capacity) {  
int photo_frame_int[capacity];

}

  • bool add_photo(photo_frame f, photo p)

    {

       int c, n;

       printf("Enter number of photos in photo frame\n");

       scanf("%d", &n);

       printf("Enter %d elements\n", n);

       for (c = 0; c < n; c++)

          scanf("%d", &photo_frame[c]);

       printf("Enter the location where you wish to insert an element\n");

       scanf("%d", &position);

       printf("Enter the value to insert\n");

       scanf("%d", &photo);

       for (c = n - 1; c >= position - 1; c--)

          photo_frame[c+1] = photo_frame[c];

       photo_frame[position-1] = photo;

       printf("photo frame \n");

       for (c = 0; c <= n; c++)

          printf("%d\n", photo_frame[c]);

       return true;

    }

Add a comment
Know the answer?
Add Answer to:
This is a question related to C can you teach me how to do whole part...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In a new file located in the same package as the class Main, create a public...

    In a new file located in the same package as the class Main, create a public Java class to represent a photograph that consists of a linear (not 2D) array of pixels. Each pixel is stored as an integer. The photograph class must have: (a) Two private fields to represent the information stored about the photograph. These are the array of integers and the date the photograph was taken (stored as a String). The values in the array must be...

  • Code in C++. Can someone make it so that the code below can be compiled? ▪...

    Code in C++. Can someone make it so that the code below can be compiled? ▪ Creating an empty queue ▪ Inserting a value ▪ Removing a value ▪ Finding the size of the queue ▪ Printing the contents of the queue ▪ Adding the contents of one queue to the end of another ▪ Merging the contents of two queues into a third, new, queue Class Attributes Your class should be implemented using a linked list and should have...

  • In this lab, using C++, you will create an abstract data type, using a doubly-linked circular...

    In this lab, using C++, you will create an abstract data type, using a doubly-linked circular structure to store the values and links. You must create it by your own and not use any existing containers. You will need a QueueNode. You can use a struct for this, as each node will not have any associated functions. It will have members for data, and the next and previous pointers. Data will be positive integers. There will be no NULL pointers....

  • Can you please write the two C++ modules below is a step by step instuctions to...

    Can you please write the two C++ modules below is a step by step instuctions to follow that will make it very easy thanks. Create a module called pqueue.cpp that implements priority queues, with a header file calledpqueue.hthat describes what pqueue.cpp exports. The interface includes the following, and nothing else. Types ItemType and PriorityType are discussed below under the refinement plan. A type, PriorityQueue. Creating a PriorityQueue object with line PriorityQueue q; makes q be an initially empty priority queue....

  • Can you please write the two C++ modules below is a step by step instuctions to follow that will ...

    Can you please write the two C++ modules below is a step by step instuctions to follow that will make it very easy thanks. Create a module called pqueue.cpp that implements priority queues, with a header file calledpqueue.hthat describes what pqueue.cpp exports. The interface includes the following, and nothing else. Types ItemType and PriorityType are discussed below under the refinement plan. A type, PriorityQueue. Creating a PriorityQueue object with line PriorityQueue q; makes q be an initially empty priority queue....

  • Can anyone help me to complete this C plus plus program? Please notice: You are required...

    Can anyone help me to complete this C plus plus program? Please notice: You are required to implement insertion sort by using smart pointer. Please notice: You are required to implement insertion sort by using smart pointer. Please notice: You are required to implement insertion sort by using smart pointer. Please notice: You are required to implement insertion sort by using smart pointer. Please notice: You are required to implement insertion sort by using smart pointer. //Implment insertion sort using...

  • Question 16 You must put your data in classes if you use C++. True False 2...

    Question 16 You must put your data in classes if you use C++. True False 2 points Question 17 Constructors are automatically invoked during class instantiation. True False 2 points Question 18 To make your data accessible to entities outside of your class, declare the members of that class as private. True False 2 points Question 19 You can make arrays of built-in types like int and double, but not of user-defined types. True False 2 points Question 20 One...

  • can you please do parts a b c and d with working out. need it in...

    can you please do parts a b c and d with working out. need it in the next 40 minutes thank you (a) Which crystal type would be expected for Nickel Oxide (Nio, Ni2+ ionic radius = 0.069nm, 02-ionic radius = 0.14nm) (2 marks) (b) In order to save weight, a composite component is to be made of aligned fibreglass and Epoxy resin to replace an aluminium component. The moduli of the fibreglass and epoxy are 85 GPa and 2.4...

  • can someone help me with this whole page questions. i dont know how to do it....

    can someone help me with this whole page questions. i dont know how to do it. please do it right and thank you 8. A student counted the number of snails at a pond in east Edmonton in April and found 38 snails. Four months later, the student recorded 214 snails in the pond. a. Calculate the growth rate of the snail population. Show ALL of your work to receive full marks. (2 marks) Record your answer to the nearest...

  • Can you please teach me how to do this question on Minitab. Thanks A machine produces...

    Can you please teach me how to do this question on Minitab. Thanks A machine produces metal rods used in an automobile suspension system. A random sample of 15 rods is selected, and the diameter is measured. The resulting data (in millimeters) are as follows: 8.24       8.25     8.20       8.23        8.24 8.21        8.26      8.26       8.20       8.25 8.23        8.23      8.19       8.28       8.24 (a) Check the assumption of normality for rod diameter. (b) Calculate a 95% two-sided confidence interval on mean rod diameter....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT