Chapter 3: Data structures/manipulation Flashcards
What is a Txt File
A structured file that contains characters of readable data
What are txt files commonly used for?
for storing small amounts of data
What are CSV Files?
A type of text file in which the elements are separated by a comma
What are the advantages of using CSV Files?
1) They allow for the storage of 2D Arrays in a more structured, readable format
2) Very useful in storing small amounts of data
Disadvantages of using CSV Files
1) Not efficient for large sets of data -> can be slow
2) Not secure, as anyone who opens the files can read its contents, which is why they are not commonly used to store sensitive data
What are XML Files?
Extensive Markup language is a method of encoding data in a file into a format that can be easily readable by both humans and the computer
Advantages of XML Files
1) Highly readable (esp by humans)
2) Makes it easier to store and transport data within, and between systems
3) The format itself defines the data and how it is structured
4) The tags (fields) can be in a different order in each record
5) The records can have different fields within them
Key difference between HTML and XML files
XML Files use pre-defined tags, created by the user.
When a solution needs to store array values or a record, what file type should be most used?
CSV. However you have to consider that:
1) The number of fields must be constant for each record
2) When writing or reading to a CSV File, the order of the fields needs to be hardcoded
What is Linear search and how does it work?
You start from the beginning of a list and go through each element one by one until you find the target element or reach the end of the list.
Advantages/Disadvantages of Linear search
Advantages:
- Simple and easy to implement.
- Works on unsorted data.
Disadvantages:
- Inefficient for large datasets
What is Binary search and how does it work?
It repeatedly divides the array in half by comparing the middle element with the target value. This process continues until the element is found or the interval is empty.
“DIVIDE AND DISCARD”
“recursion”
“order of log N”
Advantages/Disadvantages of Binary search
Advantages:
- Suitable for large sets
Disadvantages:
- Requires data to be sorted.
- Implementation can be more complex compared to linear search.
What is selection sort?
Selection sort divides the list into two parts: a sorted and an unsorted array. It repeatedly selects the smallest (or largest) element from the unsorted part and moves it to the end of the sorted part.
What is quick sort?
Quick sort is a divide-and-conquer algorithm that selects a “pivot” element and partitions the array into two subarrays: elements less than the pivot and elements greater than the pivot. It then recursively sorts the subarrays.