Basic CS-Data Structures [3i Infotech Placement]: Sample Questions 41 - 42 of 52

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 41

Data Structures
Edit

Write in Short

Short Answer▾

What are the difference between malloc () and calloc ()

Explanation

Difference between Malloc () and Calloc ()
Malloc ()Calloc ()
Allocates only single block of requested memoryAllocate multiple block or requested memory.
doesn՚t initialize the allocated memory.Initialize the allocated memory to zero.
Contains garbage valueDoes not contain garbage value.
Faster than callocLonger than malloc
Takes one argument that is number of bytes.Take two arguments those are number of blocks and size of each block.

Question 42

Data Structures

Question

MCQ▾

Which is the simplest file structure?

Choices

Choice (4)

a.

Random

b.

Indexed

c.

Sequential

d.

All of the above

Answer

c.

Explanation

Define Sequential Files
  • Sequential is the simplest file structure.
  • Contains records or other elements stored in order based some identifying data like account number.
  • Method also called pile file method.
  • When a new record is inserted, it is placed at the end of the file.
  • In the case of any modification or deletion of record, the record will be searched in the memory blocks.
  • It found it is marked for deleting and new block of record is entered.
  • In order to locate the desired data, sequential files are read starting at the beginning.
  • Ideal for storage on a sequential access device magnetic tape or on a direct access device such as magnetic disk.
  • Contrast with random file.

Advantages of Sequential File Organization

  • The design is very simple compared to other file organization.
  • Min effort involved in storing data.
  • Good method for report generation or statistical calculations.
  • Data stored in cheap magnetic tapes.

Disadvantages of Sequential File Organization

  • Sorted file method always involves the effort for sorting the record.
  • Each time any insert, update, or delete transaction is performed, file is sorted.
  • Identifying the record, inserting, updating, deleting the record, always takes some time and may make system slow.

Developed by: