So, my Java project has two CSV files that needs to read and print some sort the data from high to low. First CSV file has date, location, new_cases, new_deaths, total_cases, total_deaths format. Second CSV file has Country, location, continent, population_year, population format. What I’m trying to do is to read both data, run a function to calculate continent data,
Tag: data-structures
Can’t access my linked list methods and can’t iterate trough it
So im following along this playlist about data structures and in this video to conclude the linked list part, the professor explain we need an inner class called IteratorHelper. Video: https://www.youtube.com/watch?v=bx0ebSGUKto&list=PLpPXw4zFa0uKKhaSz87IowJnOTzh9tiBk&index=21 This is the code in my github with the linked list implementation and the main class called tester: https://github.com/Ghevi/Algos-DataStructures/tree/master/src/com/ghevi/ads/linkedlists The problem is that the tester class can’t compile. If
Java Staircase is printing in wrong direction (hackerrank)
This solution to the staircase prints the correct output, but in the opposite direction. Any idea how to alter this solution to get the desired result? Input: Expected output: Actual Output: It’s for a hackerrank easy challenge. I just want to be able to use my approach that I discovered instead of a solution I find online. Thanks! Answer You
Do arrays in Java store data or pointers
I was reading about data locality and want to use it to improve my game engine that I’m writing. Let’s say that I have created five objects at different times that are now all in different places in the memory not next to each other. If I add them all to an array, will that array only hold pointers to
String compression and decompression for data set that can be nested
My input is a compressed string of the format number[string] and the decompressed output form should be the string written number times. For example: My brute force approach in Java: Can I get some better approach with less cost? Answer We actually want to find the strings in [] and repeat it n times which is specified before the [].
Inserting a node at a specific position in a Linked list
I am given the pointer to the head node of a linked list, an integer to add to the list and the position at which the integer must be inserted. After inserting this node at the desired position I need to return the head node. The code that I have written is not working for some reason and goes in
How to merge 3 sorted arrays into 1 sorted array in Big-O(N) time?
Trying to merge 3 arrays into one so that the final array is in order. Given Merge the arrays so that the final array d = {1,1,2,3,4,5} Can’t just concatenate them and then sort the d array because that would make the time complexity larger than Big-O(N). This is what I got so far. Having problems with indexes out of
Java – Binary Tree pointer still null after initialization?
This question is very abstract and thus very hard to describe or search for, thus why I am here. It’s a very simple question however. I have the following class: What happens if I have: Notice that child is a pointer that points to either the left or the right child of root. BUT, what happens if I instantiate the
A zero-indexed array given & An equilibrium index of this array [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed last month. Improve this question A zero-indexed array A consisting of N integers is given. An equilibrium index of this array is any integer P such
Trying to print top view of a tree using two if statements
Problem Statement You are given a pointer to the root of a binary tree. Print the top view of the binary tree. You only have to complete the function. My Code: The two if statements are executed every time the function is called, but I need only one of them to execute. I tried switch but its giving constant expression