Skip to main content

All Questions

Tagged with
0 votes
0 answers
31 views

Is adding elements to a dynamic array faster than adding elements to a doubly linked list mainly because of modern CPUs?

As it's known a dynamic array eventually has to be resized when the capacity is exceeded and the capacity is being repeatedly exceed as we keep adding new elements (by adding, I mean adding to the end)...
Sebastian's user avatar
-4 votes
0 answers
53 views

How many operations are needed per added (at the end) element in an Array structure vs LinkedList and what are its consequences? [closed]

From my understanding, Adding (at the end) an item to an array requires: creating an object and allocating a new place in memory for it adding the reference to this object into the array occasionally,...
Sebastian's user avatar
1 vote
2 answers
78 views

How to translate a char array into a long and back in Java (not Long.parseLong() or String.valueOf())

I am trying to make a cryptography program using RSA, and need to be able to turn plaintext into a long. Obviously the plaintext would have to have more than just numbers in it, so using Long....
The Dog on the Log's user avatar
0 votes
1 answer
99 views

Java ArrayList and LinkedList performance [duplicate]

I know that it's a never-ending question that comes back every now and then, but I'm really confused about these two. This is what I understand about them. In theory: LinkedList is faster at adding ...
sebkaminski16's user avatar
2 votes
1 answer
104 views

Why the performance is bad if I use HashMap to solve Codility problem MinAbsSum?

Regarding the Codility problem MinAbsSum at https://app.codility.com/programmers/lessons/17-dynamic_programming/min_abs_sum/, the performance is bad if I use HashMap to solve the problem. I expect the ...
James's user avatar
  • 31
0 votes
1 answer
58 views

understanding a part of recursion for a binary search tree

Hello I basically need to implement a recursive function for insertion of a binary tree. I already implemented the chunk of insertion function (wether it's largest or smaller than root) but there's an ...
Cool Dude's user avatar
-2 votes
0 answers
44 views

I keep getting a NullPointerException and I don’t know why [duplicate]

I’m trying to create a simple program where I have an array of Person objects. Each person has a name and age, and I’m trying to print out their names. But I keep getting a NullPointerException and I ...
Sa ra's user avatar
  • 15
0 votes
1 answer
76 views

How to group anagrams using collections efficiently? [closed]

I'm working on a Java problem where I need to group words that are anagrams of each other. For instance, given the input array: ["eat", "tea", "tan", "ate", &...
Pabitra Kumar's user avatar
3 votes
2 answers
159 views

How to retrieve individual arrays from arrays of strings stored inside an ArrayList?

I'm working on an assignment where I need to take "books" from the user(a title, an author, and ISBN number, all strings), and store these books somehow, and then do various things to these ...
Bill H's user avatar
  • 33
-3 votes
4 answers
107 views

Needed Aid With Java Schoolwork - Containing Arrays & Array Searchs

Current Outputs: Is [1, 2, 3] found in [1, 2, 1, 2, 3] ? >>> false Is [1, 1, 3] found in [1, 2, 1, 2, 3] ? >>> false Needed Outputs: Is [1, 2, 3] found in [1, 2, 1, 2, 3]? >>&...
NotInferno_'s user avatar
0 votes
1 answer
40 views

Loading a model but i get this error of bytes

private MappedByteBuffer loadModelFile() throws IOException { AssetFileDescriptor fileDescriptor = getAssets().openFd("model1.tflite"); FileInputStream inputStream = new ...
Moses Musire's user avatar
2 votes
1 answer
68 views

How to Render the same model multiple times

I am trying to render the same 3D object dynamically. When I execute the method responsible for this, the 3D object is rendered on the screen only once. When I execute the method again, it gives me an ...
faztudo pedro's user avatar
-3 votes
1 answer
157 views

How can I shuffle an array using a seeded randomiser?

I must prompt for a number range and seed, then create an array of 5 numbers per row that has 2 of each number within the given range, in ASCENDING order. Following this, the order should be shuffled ...
pg777's user avatar
  • 13
1 vote
1 answer
48 views

Im implementing a python dict. I´m using a doubly linked list, it works until the first resize. How can I change my resize method to make it work?

When inserting the first 8 pairs of keys and values it works perfectly fine and the order is maintained, the problem comes after the resizing. If I insert the pairs (4,4),(5,5),(6,6),(7,7),(1,1),(2,2),...
GoldenPlus 89's user avatar
-1 votes
1 answer
44 views

NoSuchElementException and premature closure of scanner

I have made a program that reads 5 integers and outputs its polarity(positive or negative), its type(odd or even). Used Scanner.nextLine() to read the input as string and split it with .split("\s+...
Entropy's user avatar

15 30 50 per page
1
2 3 4 5
3495