problem21
.pdf
keyboard_arrow_up
School
University of Colorado, Denver *
*We aren’t endorsed by this school
Course
6040
Subject
Computer Science
Date
Apr 28, 2024
Type
Pages
46
Uploaded by hhfehiiue on coursehero.com
4/26/24, 11:10 PM
problem21
file:///Users/mingjingyang/Desktop/OMSA/6040/cse6040-pfx/problem21/problem21.html
1/46
Problem 21: Final exam, Fall 2020: The legacy of
"redlining"
Version 1.2 (Added clarification on regression part)
This problem builds on your knowledge of the Python data stack to do analyze data that contains geographic
information. It has 6
exercises, numbered 0 to 5
. There are 13 available points.
However, to earn 100%, the
threshold is just 10 points.
(Therefore, once you hit 10
points, you can stop. There is no extra credit for
exceeding this threshold.)
Each exercise builds logically on the previous one, but you may solve them in any order. That is, if you can't
solve an exercise, you can still move on and try the next one. However, if you see a code cell introduced by
the phrase, "Sample result for ...", please run it.
Some demo cells in the notebook may depend on these
precomputed results.
The point values of individual exercises are as follows:
Exercise 0: 2 points
Exercise 1: 3 points
Exercise 2: 2 points
Exercise 3: 2 points
Exercise 4: 2 points
Exercise 5: 2 points
Pro-tips.
All test cells use randomly generated inputs.
Therefore, try your best to write solutions that do not
assume too much. To help you debug, when a test cell does fail, it will often tell you exactly what
inputs it was using and what output it expected, compared to yours.
If you need a complex SQL query, remember that you can define one using a triple-quoted (multiline)
string
(https://docs.python.org/3.7/tutorial/introduction.html#strings).
If your program behavior seem strange, try resetting the kernel and rerunning everything.
If you mess up this notebook or just want to start from scratch, save copies of all your partial
responses and use Actions
Reset Assignment
to get a fresh, original copy of this notebook.
(Resetting will wipe out any answers you've written so far, so be sure to stash those somewhere safe if
you intend to keep or reuse them!)
If you generate excessive output (e.g., from an ill-placed print
statement) that causes the notebook
to load slowly or not at all, use Actions
Clear Notebook Output
to get a clean copy. The
clean copy will retain your code but remove any generated output. However
, it will also rename
the
notebook to clean.xxx.ipynb
. Since the autograder expects a notebook file with the original name,
you'll need to rename the clean notebook accordingly.
Good luck!
4/26/24, 11:10 PM
problem21
file:///Users/mingjingyang/Desktop/OMSA/6040/cse6040-pfx/problem21/problem21.html
2/46
Background
During the economic Great Depression of the 1930s, the United States government began "rating"
neighborhoods, on a letter-grade scale of "A" ("good") to "D" ("bad"). The purpose was to use such grades to
determine which neighborhoods would qualify for new investments, in the form of residential and business
loans.
But these grades also reflected racial and ethnic bias toward the residents of their neighborhoods. Nearly 100
years later, the effects have taken the form of environmental and economic disparaties.
In this notebook, you will get an idea of how such an analysis can come together using publicly available data
and the basic computational data processing techniques that appeared in this course. (And after you finish the
exam, we hope you will try the optional exercise at the end and refer to the "epilogue" for related reading.)
Goal and workflow.
Your goal is to see if there is a relationship between the rating a neighborhood received in
the 1930s and two attributes we can observe today: the average temperature of a neighborhood and the
average home price.
Temperature tells you something about the local environment. Areas with more parks, trees, and green
space tend to experience more moderate temperatures.
The average home price tells you something about the wealth or economic well-being of the
neighborhood's residents.
Your workflow will consist of the following steps:
1. You'll start with neighborhood rating data, which was collected from public records as part of a
University of Richmond study on redlining policies
(https://dsl.richmond.edu/panorama/redlining)
2. You'll then combine these data with satellite images, which give information about climate. These data
come from the US Geological Survey
(https://usgs.gov/).
3. Lastly, you'll merge these data with home prices from the real estate website, Zillow
(https://zillow.com).
Note: The analysis you will perform is correlational, but the deeper research that inspired this
problem tries to control for a variety of factors and suggests causal effects.
Part 0: Setup
At a minimum, you will need the following modules in this problem. They include a new one we did not cover
called geopandas
. While it may be new to you, if you have mastered pandas
, then you know almost everything
you need to use geopandas
. Anything else you need will be given to you as part of this problem, so don't be
intimidated!
4/26/24, 11:10 PM
problem21
file:///Users/mingjingyang/Desktop/OMSA/6040/cse6040-pfx/problem21/problem21.html
3/46
In [1]:
import
sys
print(f"* Python version: {sys.version}
")
# Standard packages you know and love:
import
pandas
as
pd
import
numpy
as
np
import
scipy
as
sp
import
matplotlib.pyplot
as
plt
import
geopandas
print("* geopandas version:", geopandas.__version__)
Run the next code cell, which will load some tools needed by the test cells.
In [2]:
### BEGIN HIDDEN TESTS
%
load_ext
autoreload
%
autoreload
2
### END HIDDEN TESTS
from
testing_tools
import
data_fn, load_geopandas, load_df, load_pickl
e
from
testing_tools
import
f_ex0__sample_result
from
testing_tools
import
f_ex1__sample_result
from
testing_tools
import
f_ex2__sample_result
from
testing_tools
import
f_ex3__sample_result
from
testing_tools
import
f_ex4__sample_result
from
testing_tools
import
f_ex5__sample_result
Part 1: Neighborhood ratings
The neighborhood rating data is stored in a special extension of a pandas DataFrame
called a GeoDataFrame
.
Let's load the data into a variable named neighborhood_ratings
and have a peek at the first few rows:
* Python version: 3.7.5 (default, Dec 18 2019, 06:24:58) [GCC 5.5.0 20171010]
* geopandas version: 0.6.2
4/26/24, 11:10 PM
problem21
file:///Users/mingjingyang/Desktop/OMSA/6040/cse6040-pfx/problem21/problem21.html
4/46
In [3]:
neighborhood_ratings = load_geopandas('fullDownload.geojson')
print(type(neighborhood_ratings))
neighborhood_ratings.head()
Each row is a neighborhood. Its location is given by name, city, and a two-letter state abbreviation code (the
name
, city
, and state
columns, respectively). The rating assigned to a neighborhood is a letter, 'A'
, 'B'
,
'C'
, or 'D'
, given by the holc_grade
column.
In addition, there is special column called geometry
. It contains a geographic outline of the boundaries of this
neighborhood. Let's take a look at row 4 (last row shown above):
Opening geopandas data file, './resource/asnlib/publicdata/fullDownloa
d.geojson' ...
<class 'geopandas.geodataframe.GeoDataFrame'>
Out[3]:
state city
name
holc_id holc_grade area_description_data geometry
0
AL
Birmingham
Mountain
Brook
Estates
and
Country
Club
Garden...
A1
A
{'5': 'Both sales and
rental prices in 1929
we...
MULTIPOLYG
(((-86.75678
33.49754,
-86.75692 ..
1
AL
Birmingham
Redmont
Park,
Rockridge
Park,
Warwick
Manor, a...
A2
A
{'5': 'Both sales and
rental prices in 1929
we...
MULTIPOLYG
(((-86.75867
33.50933,
-86.76093 ..
2
AL
Birmingham
Colonial
Hills, Pine
Crest
(outside
city limits)
A3
A
{'5': 'Generally
speaking, houses are
not buil...
MULTIPOLYG
(((-86.75678
33.49754,
-86.75196 ..
3
AL
Birmingham
Grove
Park,
Hollywood,
Mayfair,
and
Edgewood
s...
B1
B
{'5': 'Both sales and
rental prices in 1929
we...
MULTIPOLYG
(((-86.80111
33.48071,
-86.80099 ..
4
AL
Birmingham
Best
section of
Woodlawn
Highlands
B10
B
{'5': 'Both sales and
rental prices in 1929
we...
MULTIPOLYG
(((-86.74923
33.53332,
-86.74916 ..
4/26/24, 11:10 PM
problem21
file:///Users/mingjingyang/Desktop/OMSA/6040/cse6040-pfx/problem21/problem21.html
5/46
In [4]:
g4_example = neighborhood_ratings.loc[4, 'geometry']
print("* Type of `g4_example`:", type(g4_example))
print("
\n
* Contents of `g4_example`:", g4_example)
print("
\n
* A quick visual preview:")
display(g4_example)
The output indicates that this boundary is stored a special object type called a MultiPolygon
. It is usually a
single connected polygon, but may also be the union of multiple such polygons.
The coordinates of the multipolygon's corners are floating-point values, and correspond to longitude and
latitude values
(https://www.latlong.net/). But for this notebook, the exact format won't be important. Simply
treat the shapes as being specified in some way via a collection of two-dimensional coordinates
measured in arbitrary units.
Lastly, observe that calling display()
on a MultiPolygon
renders a small picture of it.
* Type of `g4_example`: <class 'shapely.geometry.multipolygon.MultiPol
ygon'>
* Contents of `g4_example`: MULTIPOLYGON (((-86.749227 33.533325, -86.
749156 33.530809, -86.75388599999999 33.529075, -86.754373 33.529382, -86.754729 33.529769, -86.754729 33.530294, -86.75604800000001 33.5312
25, -86.75539499999999 33.532008, -86.754456 33.532335, -86.753196 33.
531483, -86.749714 33.533295, -86.749227 33.533325)))
* A quick visual preview:
4/26/24, 11:10 PM
problem21
file:///Users/mingjingyang/Desktop/OMSA/6040/cse6040-pfx/problem21/problem21.html
6/46
Exercise 0: Filtering ratings (2 points)
Complete the function,
def
filter_ratings(ratings, city_st, targets=None):
...
so that it filters ratings data by its city and state name, along with a set of targeted letter grades. In particular,
the inputs are:
ratings
: A geopandas GeoDataFrame
similar to the neighborhood_ratings
example above.
city_st
: The name of a city and two-letter state abbreviation as a string, e.g., city_st = 'Atlanta, GA'
to request only rows for Atlanta, Georgia.
targets
: A Python set containing zero or more ratings, e.g., targets = {'A', 'C'}
to request
only rows having either an 'A'
grade or a 'C'
grade.
The function should return a copy of the input GeoDataFrame
that has the same columns as ratings
but only
rows that match both
the desired city_st
value and
any one of the target ratings.
For example, suppose ratings
is the following:
city
state holc_grade holc_id
(... other cols not shown ...)
geometry
0 Chattanooga TN
C
C4
...
MULTIPOLYGON(...)
1 Augusta
GA
C
C5
...
MULTIPOLYGON(...)
2 Chattanooga TN
B
B7
...
MULTIPOLYGON(...)
3 Chattanooga TN
A
A1
...
MULTIPOLYGON(...)
4 Augusta
GA
B
B4
...
MULTIPOLYGON(...)
5 Augusta
GA
D
D11
...
MULTIPOLYGON(...)
6 Augusta
GA
B
B1
...
MULTIPOLYGON(...)
7 Chattanooga TN
D
D8
...
MULTIPOLYGON(...)
8 Chattanooga TN
C
C7
...
MULTIPOLYGON(...)
Then filter_ratings(ratings, 'Chattanooga, TN', {'A', 'C'})
would return
city
state holc_grade holc_id
(... other cols not shown ...)
geometry
0 Chattanooga TN
C
C4
...
MULTIPOLYGON(...)
3 Chattanooga TN
A
A1
...
MULTIPOLYGON(...)
8 Chattanooga TN
C
C7
...
MULTIPOLYGON(...)
All of these rows match 'Chattanooga, TN'
and have a holc_grade
value of either 'A'
or 'C'
. Other
columns, such as holc_id
and any columns not shown, would be returned as-is from the original input.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
Dijkstra's algorithm Weight Class Implementationlanguage : C++
Note : Skelton Files Provided
Please check the linksproject Details:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/
Files:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/src/
Please provide clear and complete solution for thumps up.
arrow_forward
The question should be done in C++, please give explanation and running result.
1. For this question, we need to provide more information about where the mismatch of the text file is happening.
Write a recursive function called list_mismatched_lines that takes 2 filenames as input arguments and displays to the screen all mismatched lines in those files. This function should use hashing techniques and shall not compare strings to detect mismatch.
The signature of this function should be:
void list_mismatched_lines(std::string file1, std::string file2);
In file1.txt, it contains "My dear C++ class. I hope that you enjoy this assignment. "
In file2.txt, it contains "My dear C++ class. I hope that you like this assignment. "
Example: Running the following line of code, should print to the screen the mismatched lines only, from both files.
list_mismatched_lines(file1, file2);
The following output should be seen on the screen:
file1.txt: I hope that you enjoy this assignment.file2.txt:…
arrow_forward
In C++, how can one easily duplicate a set of shared pointers into another array? Make a list of various solutions to the situation you've been given. Is it true that copying shared pointers also copies the objects they manage? Explain
arrow_forward
QUESTION:
NOTE: This assignment is needed to be done in OOP(c++/java), the assignment is a part of course named data structures and algorithm.
A singly linked circular list is a linked list where the last node in the list points to the first node in the list. A circular list does not contain NULL pointers.
A good example of an application where circular linked list should be used is a items in the shopping cart
In online shopping cart, the system must maintain a list of items and must calculate total bill by adding amount of all the items in the cart,
Implement the above scenario using Circular Link List. Do Following:
First create a class Item having id, name, price and quantity provide appropriate methods and then Create Cart/List class which holds an items object to represent total items in cart and next pointer Implement the method to add items in the array, remove an item and display all items.
Now in the main do the following
Insert Items in list
Display all items.
Traverse…
arrow_forward
Y3
Using C++
To test your understanding of recursion, you are charged with creating a recursive, singly linked list. You will need to make the class yourself for this data structure. This repository already contains the List ADT and a driver that will create a TUI (terminal user interface) program that uses your data structure to generate a recursive art animation. Submissions that do not compile will receive a zero. You can work on this by yourself or with one other person. LinkedList This class will represent the data structure. Since we want this data structure to be generic, you need to make it a class template. Create two files for this class: a header file (LinkedList.hpp) and an implementation file (LinkedList.tpp). Place these two files in the src directory. It needs to inherit from the List abstract class using the public access specifier. The following are implementation notes for the class. The majority of methods need to be recursive and optimized via tail recursion…
arrow_forward
PYTHON + DATAFRAMES (pandas)
import pandas as pd
crimeData = {'agency_code': ['UT01803','TXSPD00','CA03711','MOSPD00','NY05101'],
'location': ['Salt Lake City, UT','San Antonio, TX','San Diego, CA','St. Louis, MO','Suffolk County, NY'],
'population': [191992,1463586,1400467,317095,1341453],
'homicides': [8,94,37,188,24],
'assaults': [874,5465,3601,3521,895],
'robberies': [469,1986,1378,1790,677]}
df = pd.DataFrame(crimeData)
df.set_index('agency_code', inplace=True)
homicidesPerCapita = {'homicides_per_capita':[4,6,3,59,2,9]}
df2 = pd.DataFrame(homicidesPerCapita)
df3 = df.join(df2)
df3
Questions:
Why is printing homicides_per_capita as NaN?
Sort the DataFrame by homicides per capita from greatest to least on the original DataFrame
Filter/reduce the DataFrame down to only those with more than 50 total homicides OR (not 'and') over 5000 assaults
Print the DataFrame
Thanks!
arrow_forward
You are working for GreatDataStructures Inc. You have to pick a data structure for a problem
that requires accessing all the stored elements quickly as well as adding elements to and
removing elements from the end of the list of elements. The number of elements in the list is
not known. The best data structure to choose is
a linked list with no tail reference
a linked list with a tail reference
a doubly-linked list
an array list
O an array stack
arrow_forward
Python lists are commonly used to store data types. Lists are a collection of information typically called a container. Think of a physical container that can hold all kinds of objects, not just one object of the same type. Python includes a built-in list type called a list. They can be managed by many built-in functions that help fill, iterate over, add to, and delete them.
Why is it useful to store information with different data types? When do you choose to use a list over a dictionary? Provide a code example that supports your comments.
arrow_forward
Erlang File
-module(exam).
-compile(export_all).
-include_lib("eunit/include/eunit.hrl").
Part A Implement a function called min which takes a tuple of two numeric values and returns the lower value of the two.Implementation notes:• If needed, use Erlang function guards• Do NOT use the if or case structuresSample calls:> exam:min({3, 4}).3> exam:min({4, 3}).3
arrow_forward
Question 2
A doubly linked list may be referred to as a complex type of linked list in which a node contains a
pointer to the previous node (previous pointer) as well as the next node (next pointer) in the
sequence. You have been given the following fruits: Apple, Lemon, Orange, Grape, Strawberry,
Mango, Banana, Peach. Write a Python program that will insert these fruits into a sorted doubly
linked list.
arrow_forward
Write a menu-driven C++ program to manage your college course history and plans, named as you wish. It should work something like this:
Array size: 0, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-165[ENTER]Enter the year for Comsc-165 [like 2020]: 2016[ENTER]Enter the units for Comsc-165 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-165 [A, B,..., X if still in progress or planned]: x[ENTER]Array size: 1, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-110[ENTER]Enter the year for Comsc-110 [like 2020]: 2015[ENTER]Enter the units for Comsc-110 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-110 [A, B,..., X if still in progress or planned]: A[ENTER]Array size: 2, capacity: 2MENUA Add a courseL List all coursesC Arrange by…
arrow_forward
Implement 5 functions in Python that would sort an unsorted list, i.e
def bubble_sort(my_list):
def selection_sort(my_list):
def insertion_sort(my_list):
def quick_sort(mylist):
def insertion_sort(mylist, left, right):
Provide a main that uses each of the above functions to sort a list of length 100 and make sure it works as expected
Step 2
Add lines of code to the above functions so that apart from sorting the received list, it calculates T(n) and returns it. This means that each of the above functions will have a
return value which is the exact number of operations executed to perform the sort.
Use a main to test yout T(n) calculation. A good way of testing your T(n) is this. Send a best case scenario, a worst case scenario and an average scenario to your sort
function and see what numbers come out for your T(n). Explain what best, worst and average case scenarios will be for a sorting algorithm.
Step 3
Use the sort functions with T(n) calculation feature to plot T(n) vs. n for a…
arrow_forward
TRUE OR FALSE
1. One disadvantage of Boolean type is readability
2. When string length is specified at the declaration time then we call it Static Length
3. In stack-dynamic array subscript ranges are dynamically bound
4. Access to record elements is slower than access to array
5. It is possible to check type (type checking) when using free union
arrow_forward
The statement "Linear collection of self-referential class objects, called nodes,
connected by pointer links" is best describing a/an
7.
O A. data structure
B. union
O c. array list
O D. linked list
arrow_forward
How simple is it to transfer shared references into another array in C++? List approaches to tackle the issue. Do shared pointers copy the objects they control? Explain
arrow_forward
In C++, Consider a singly linked list where each node contains two fields – integer dataand node type pointer next. The head pointer of the list, a position, and a valueof data is given. You have to insert a node with the given value at the givenposition. You have to consider any position including first or last. You have toImplement an insert operation as per the above specification.
arrow_forward
In c++ , perform data traversal before and after deletion operation.
( Drop code in words , explain the code and drop the screenshot of output as well )
arrow_forward
can someone help me with this in C++ (not Java)
create a program that reads in two matrices from two different text files. Should use a singly or double linked list to store the two matrices and perform the following operations on them:
- Add, Subtract, Mulitply, Transpose, and Determinant
Requirements:
Use singly or doubly linked list date structures only:
- No other library methods or existing collection framework.
- No use of Array, ArrayList, List, or Vectors for storing.
- No two-dimensional arrays.
- Input files can only be read Exactly Once for all operations.
For the determinant operation, you may augment your linked list node to retain row/column id and employ recursion to directly implement the standard method for computing determinant of a matrix. You are encouraged to design your own node representation (e.g., each node element has two pointers: one to its next right and another to its next bottom element that facilitate both horizontal and vertical traversals like one gets…
arrow_forward
Java/Data Structures: The Java Class Library implementation of the interface list return null when an index is out of range.
True or False
arrow_forward
PYTHON!!!
Write a function that will filter course grades that are stored in a list, creating and returning a new list. Your implementation must have the following rules:
- The function must accept two (and only two) parameters:
The first is: the maximum integer value for any grade to remain in the list (any value above the maximum will be filtered and removed from the list).
The second is: the list of grades (you can assume the list contains only integer values)
- The function must return a new list and not modify the existing list.
- The function must use a list comprehension to filter the existing list and create the new list that is returned.
- DO NOT USE THE: built-in-"filter" function.
arrow_forward
### Q5: Reduce No Change Python
def reduce_no_change(fn, lst, base):
"""Same as Q4. However, preserve the lst in this problem.
Object can be any python type which the input
Not Allowed To Import Libraries
Args:
fn (function): Combination function which takes in two arguments and return
an value with the same type as the second argument
lst (List): A list of any type
base (Object): A value of custom type which fn can handle.
Returns:
Object: A value after applying fn on lst.
>>> reducer = lambda x, y: x + y
>>> lst = [1, 2, 3]
>>> a = reduce_lst(reducer, lst, 0)
>>> a # a = reducer(reducer(reducer(base, lst[0]), lst[1]), lst[2])
6
>>> lst
>>> [1, 2, 3] # we preserve the list
"""
### Modify your code here
### Modify your code here
arrow_forward
Assignment 6 - More on ListsWrite pseudo-code not Python for problems requiring code. You are responsible for the appropriate level of detail.The questions in this assignment give you the opportunity to explore a new data structure and to experiment with the hybrid implementation in Q3.
3. Write a set of routines for implementing several stacks and queues within a single array. Hint: Look at the lecture material on the hybrid implementation.
arrow_forward
Implement a function grandparents (person, family) with the following specification.
Input: A string containing a person's name, person, and a family tree database family as specified above.
Output: A list containing only the names of the grandparents of person that are stored in the database, or
an empty list if no such information exists in the database (including if the person themselves are not in
the database).
For example, grandparents should behave as follows:
>>> duck_tree = [['Donald Duck','Quackmore Duck', 'Hortense McDuck'],
['Della Duck', 'Quackmore Duck', 'Hortense McDuck'],
['Hortense McDuck', 'Fergus McDuck', 'Downy ODrake'],
['Scrooge McDuck', 'Fergus McDuck', 'Downy ODrake'],
['Fergus McDuck', 'Dingus McDuck', 'Molly Mallard'],
['Huey Duck', None, 'Della Duck'],
['Dewey Duck', None, 'Della Duck'],
['Louie Duck', None, 'Della Duck']]
>>> sorted (grandparents ('Scrooge McDuck', duck_tree))
['Dingus McDuck', 'Molly Mallard']
>>> sorted (grandparents ('Louie Duck',…
arrow_forward
Computer Science
Can someone help me create a program that is a library management system? So, the program will manage a library collection of books, allowing the user to add books, check them out, and return them. possibly use data structures such as linked lists or hash tables which will keep track of the availability of the books.
demonstrate its function and discuss your experiences in creating it. Topics worthy of discussion include details of the implementation itself (language choice, class design, etc), difficulties that you faced in implementing it (learning new techniques, significant errors encountered, etc), and maybe a project post-mortem discussing whether or not you would do anything differently, knowing what you do about it at the end (e.g. using a linked list instead of an array).
c++
arrow_forward
In C++, how do I read a file with numbers
Such as
1,2
3,4
5,6
and place it into a linked list with x,y values
Without stringstream or sstream and vectors
arrow_forward
m = int(temp[1])
IndexError: list index out of range
line 3, in <module> m = int(temp[10])IndexError: list index out of range
when i ran this test case
input:
3 jun3 Jin1 Li2 Kitty2 Josh3 Bob1 Dave2 Jose1 David3 Rob3 Anne3 Ann2 Kevin2 Lara1 ALI3 Xin
expected output:
Li Dave David ALI Kitty Josh Kevin Lara jun Bob Anne Ann Xin
arrow_forward
in c++, apply non-linear data structures to solve simple problems.
Question - Implement list using array, Your program should be menu driven use functional approach
Program should have following functions
1. Insertion
2. Search
3. Traversal
4. Deletion
5. Count
6. Display
( Drop coding in words with screenshot of output as well )
arrow_forward
in c++ language , apply non-linear data structures to solve simple problems.
Question - imagine having a List L1 in c++ ,delete all the nodes having even numbers into info part from the list L1 and insert into List L2 and all the numbers having odd numbers into list L3.
(Drop coding in words with screenshot of output as well)
arrow_forward
Type of data structures, data values of different types are grouped and stored. Which of the following is the correct answer?
a. homogenous
b. pointer
c. linked list
d. non-homogenous
arrow_forward
in c++, apply non-linear data structures to solve simple problems.
Question - imagine having a List L1,delete all the nodes having even numbers into info part from the list L1 and insert into List L2 and all the numbers having odd numbers into list L3.
(Drop coding in words with screenshot of output as well)
arrow_forward
C++
Can someone answer the following code below in C++: Please add to the project a print statement that says how long each version ran in milliseconds please!
Version 1 of the process creation hierarchy uses linked lists to keep track of child processes as described in section "The process control block", subsection "The PCB data structure".
For the purposes of performance evaluation, the PCBs are simplified as follows:
All PCBs are implemented as an array of size n.
Each process is referred to by the PCB index, 0 through n-1.
Each PCB is a structure consisting of only the two fields:
parent: a PCB index corresponding to the process's creator
children: a pointer to a linked list, where each list element contains the PCB index of one child process
The necessary functions are simplified as follows:
create(p) represents the create function executed by process PCB[p]. The function creates a new child process PCB[q] of process PCB[p] by performing the following tasks:
allocate a…
arrow_forward
Introduction
For this assignment, you are to write a program which implements a Sorted List data structure using a circular
array-based implementation and a driver program that will test this implementation.
The Sorted List ADT is a linear collection of data in which all elements are stored in sorted order. Your
implementation has to store a single int value as each element of the list and support the following operations:
1. add(x) – adds the integer x to the list. The resulting list should remain sorted in increasing order. The time
complexity of this operation should be 0(N), where N is the size of the list.
2. removefirst() - deletes the first integer from the list and returns its value. The remaining list should
remain sorted. Time complexity of this operation should be 0(1).
3. removelast() – deletes the last integer from the list and returns its value. The remaining list should
remain sorted. Time complexity of this operation should be 0(1).
4. exists(x) – returns true if the…
arrow_forward
Hashing Project in Python to Extract Features of Names
You are given the following three functions. They take plain text names and covert then into features vefctors so that you can work with them in a classification system.
Let's check your understanding of Python function. Add notes to each line describing what is happening in these functions.
FUNCTION ONE:
def hashfeatures(baby, B, FIX):
"""
Input:
baby : a string representing the baby's name to be hashed
B: the number of dimensions to be in the feature vector
FIX: the number of chunks to extract and hash from each string
Output:
v: a feature vector representing the input string
"""
v = np.zeros(B)
for m in range(FIX):
featurestring = "prefix" + baby[:m]
v[hash(featurestring) % B] = 1
featurestring = "suffix" + baby[-1*m:]
v[hash(featurestring) % B] = 1
return v
FUNCTION TWO:
def name2features(filename, B=128, FIX=3, LoadFile=True):
"""
Output:
X : n feature…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- Dijkstra's algorithm Weight Class Implementationlanguage : C++ Note : Skelton Files Provided Please check the linksproject Details:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/ Files:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/src/ Please provide clear and complete solution for thumps up.arrow_forwardThe question should be done in C++, please give explanation and running result. 1. For this question, we need to provide more information about where the mismatch of the text file is happening. Write a recursive function called list_mismatched_lines that takes 2 filenames as input arguments and displays to the screen all mismatched lines in those files. This function should use hashing techniques and shall not compare strings to detect mismatch. The signature of this function should be: void list_mismatched_lines(std::string file1, std::string file2); In file1.txt, it contains "My dear C++ class. I hope that you enjoy this assignment. " In file2.txt, it contains "My dear C++ class. I hope that you like this assignment. " Example: Running the following line of code, should print to the screen the mismatched lines only, from both files. list_mismatched_lines(file1, file2); The following output should be seen on the screen: file1.txt: I hope that you enjoy this assignment.file2.txt:…arrow_forwardIn C++, how can one easily duplicate a set of shared pointers into another array? Make a list of various solutions to the situation you've been given. Is it true that copying shared pointers also copies the objects they manage? Explainarrow_forward
- QUESTION: NOTE: This assignment is needed to be done in OOP(c++/java), the assignment is a part of course named data structures and algorithm. A singly linked circular list is a linked list where the last node in the list points to the first node in the list. A circular list does not contain NULL pointers. A good example of an application where circular linked list should be used is a items in the shopping cart In online shopping cart, the system must maintain a list of items and must calculate total bill by adding amount of all the items in the cart, Implement the above scenario using Circular Link List. Do Following: First create a class Item having id, name, price and quantity provide appropriate methods and then Create Cart/List class which holds an items object to represent total items in cart and next pointer Implement the method to add items in the array, remove an item and display all items. Now in the main do the following Insert Items in list Display all items. Traverse…arrow_forwardY3 Using C++ To test your understanding of recursion, you are charged with creating a recursive, singly linked list. You will need to make the class yourself for this data structure. This repository already contains the List ADT and a driver that will create a TUI (terminal user interface) program that uses your data structure to generate a recursive art animation. Submissions that do not compile will receive a zero. You can work on this by yourself or with one other person. LinkedList This class will represent the data structure. Since we want this data structure to be generic, you need to make it a class template. Create two files for this class: a header file (LinkedList.hpp) and an implementation file (LinkedList.tpp). Place these two files in the src directory. It needs to inherit from the List abstract class using the public access specifier. The following are implementation notes for the class. The majority of methods need to be recursive and optimized via tail recursion…arrow_forwardPYTHON + DATAFRAMES (pandas) import pandas as pd crimeData = {'agency_code': ['UT01803','TXSPD00','CA03711','MOSPD00','NY05101'], 'location': ['Salt Lake City, UT','San Antonio, TX','San Diego, CA','St. Louis, MO','Suffolk County, NY'], 'population': [191992,1463586,1400467,317095,1341453], 'homicides': [8,94,37,188,24], 'assaults': [874,5465,3601,3521,895], 'robberies': [469,1986,1378,1790,677]} df = pd.DataFrame(crimeData) df.set_index('agency_code', inplace=True) homicidesPerCapita = {'homicides_per_capita':[4,6,3,59,2,9]} df2 = pd.DataFrame(homicidesPerCapita) df3 = df.join(df2) df3 Questions: Why is printing homicides_per_capita as NaN? Sort the DataFrame by homicides per capita from greatest to least on the original DataFrame Filter/reduce the DataFrame down to only those with more than 50 total homicides OR (not 'and') over 5000 assaults Print the DataFrame Thanks!arrow_forward
- You are working for GreatDataStructures Inc. You have to pick a data structure for a problem that requires accessing all the stored elements quickly as well as adding elements to and removing elements from the end of the list of elements. The number of elements in the list is not known. The best data structure to choose is a linked list with no tail reference a linked list with a tail reference a doubly-linked list an array list O an array stackarrow_forwardPython lists are commonly used to store data types. Lists are a collection of information typically called a container. Think of a physical container that can hold all kinds of objects, not just one object of the same type. Python includes a built-in list type called a list. They can be managed by many built-in functions that help fill, iterate over, add to, and delete them. Why is it useful to store information with different data types? When do you choose to use a list over a dictionary? Provide a code example that supports your comments.arrow_forwardErlang File -module(exam). -compile(export_all). -include_lib("eunit/include/eunit.hrl"). Part A Implement a function called min which takes a tuple of two numeric values and returns the lower value of the two.Implementation notes:• If needed, use Erlang function guards• Do NOT use the if or case structuresSample calls:> exam:min({3, 4}).3> exam:min({4, 3}).3arrow_forward
- Question 2 A doubly linked list may be referred to as a complex type of linked list in which a node contains a pointer to the previous node (previous pointer) as well as the next node (next pointer) in the sequence. You have been given the following fruits: Apple, Lemon, Orange, Grape, Strawberry, Mango, Banana, Peach. Write a Python program that will insert these fruits into a sorted doubly linked list.arrow_forwardWrite a menu-driven C++ program to manage your college course history and plans, named as you wish. It should work something like this: Array size: 0, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-165[ENTER]Enter the year for Comsc-165 [like 2020]: 2016[ENTER]Enter the units for Comsc-165 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-165 [A, B,..., X if still in progress or planned]: x[ENTER]Array size: 1, capacity: 2MENUA Add a courseL List all coursesC Arrange by courseY arrange by YearU arrange by UnitsG arrange by GradeQ Quit...your choice: a[ENTER]Enter a courses' name: Comsc-110[ENTER]Enter the year for Comsc-110 [like 2020]: 2015[ENTER]Enter the units for Comsc-110 [0, 1, 2,...]: 4[ENTER]Enter the grade for Comsc-110 [A, B,..., X if still in progress or planned]: A[ENTER]Array size: 2, capacity: 2MENUA Add a courseL List all coursesC Arrange by…arrow_forwardImplement 5 functions in Python that would sort an unsorted list, i.e def bubble_sort(my_list): def selection_sort(my_list): def insertion_sort(my_list): def quick_sort(mylist): def insertion_sort(mylist, left, right): Provide a main that uses each of the above functions to sort a list of length 100 and make sure it works as expected Step 2 Add lines of code to the above functions so that apart from sorting the received list, it calculates T(n) and returns it. This means that each of the above functions will have a return value which is the exact number of operations executed to perform the sort. Use a main to test yout T(n) calculation. A good way of testing your T(n) is this. Send a best case scenario, a worst case scenario and an average scenario to your sort function and see what numbers come out for your T(n). Explain what best, worst and average case scenarios will be for a sorting algorithm. Step 3 Use the sort functions with T(n) calculation feature to plot T(n) vs. n for a…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education