Questions tagged [insertion]

place into or between other items in an enumeration

578 questions
2
votes
1 answer

"*** stack smashing detected ***: ./a.out terminated Aborted (core dumped)" - array insertion

I got the following code over the Internet to insert an element in an array. My question is that "how could the size of the array can be incremented especially​ at first insertion and garbage is printed at every execution of printing for loop?". I'm…
Revaapriyan
  • 309
  • 2
  • 4
  • 20
2
votes
3 answers

Insert value to every other array index in Ruby

I need to turn an array of integers like [1,2,3] into an array in which the integers are each followed by a zero: [1,0,2,0,3,0]. My best guess, which works but looks jenky: > [1,2,3].flat_map{|i| [i,0]} => [1,0,2,0,3,0]
omikes
  • 8,064
  • 8
  • 37
  • 50
2
votes
1 answer

C Error: expression must have arithmetic or pointer type

typedef struct node { Record data; struct node *next; }Node; Node *head = NULL; void addRecord(Record x) { Node *previousNode = NULL; Node *newNode; Node *n; newNode = (Node*)malloc(sizeof(Node)); newNode->data =…
Simon Sultana
  • 235
  • 1
  • 2
  • 13
2
votes
0 answers

Inserting into n-child tree in Python

I am trying to implement a tree for the travelling salesperson problem. My particular tree has 5 destinations which are fully connected to each other. One of the destinations is guaranteed to always be the starting destination and that you are only…
2
votes
1 answer

Sorting an array with Insertion Sort

My task is to write a function naive_sort() that takes an array of random generated integers as a parameter and sorts them. I need to use Insertion Sort. I have come to a point where i have no idea how to fix the problem, when i run the program…
Lurem
  • 29
  • 5
2
votes
1 answer

Insertion operator overloading for own stream class

In C++ books I meet the descriptions about how to overload insertion operators for putting data to std::ostream. But when I studied neoengine sources I met this code: File &File::operator << ( const char *pszData ) { if( m_bBinary ) do…
graveman
  • 93
  • 6
2
votes
1 answer

How to know the insertion/update history of one Cassandra table?

There is one table (or called column family) in Cassandra. I want to know how many records of this table were inserted or updated since a given timestamp. How to do it?
Finix
  • 131
  • 14
2
votes
1 answer

Java JSpinner Prevent Letter Insertion

A JSpinner is used to store a number in my application (with a SpinnerNumberModel). As expected, the spinner doesn't allow invalid characters (letters, symbols, etc.) to be stored. However, those characters do appear in the spinner component when I…
user356178
2
votes
1 answer

Singly-Linked List: Insert node between 2 nodes

I am working on a project to simulate memory segments arriving and departing virtual memory. When a segment departs, or memory is not occupied, it becomes a hole. Constraints: "head" node must always point to the lowest address in…
Evan Bechtol
  • 2,855
  • 2
  • 18
  • 36
2
votes
2 answers

Binary Tree Structure

I am trying to solve this problem where a new joining peer will be given an index [0,1,2, ... n-1] based on how many peer objects already exist (e.g. 8 exist -> new peer will get index 8). I want to add these peer objects into a binary tree based on…
JerryFox
  • 615
  • 2
  • 13
  • 25
2
votes
3 answers

STL Map: What does this command mean?

I've come across a solution of a competition problem that uses the STL Map, with a different kind of insertion that I've already known. I know these kind of insertions (and their differences): Map[key] = value; and…
William Studart
  • 321
  • 1
  • 3
  • 12
2
votes
1 answer

Binary search tree insertion - root always null

I have ds code for inserting values in a binary search tree using recursion. The problem is that the root always remains null. Upon execution, the 1st printf() prints 10 but the 2nd printf (after insertRec(10)) does not print anything as root is…
2
votes
2 answers

Disable code in comment system

I have created a comment system where people comment on a topic. The comment is stored in a SQL database. Now, to avoid malicious links, or JS/HTML/PHP code to be inserted into the comment which could be executed.. How do I prevent this? Suppose the…
2
votes
2 answers

pointer vs double pointer for Linked List and Binary Tree

For single linklist 1.1. This is what I saw from a tutorial, I only wrote the important part. sortedInsert(Node **root, int key){}; int main(){ Node *root = &a; sortedInsert(&root, 4); } 1.2. However I just used pointer rather than double…
2
votes
1 answer

How to perform "all or nothing" operation with mongoDB?

I need insert some elements in a field array on a document. Well... I know that Mongo has atomic Update.Push... The fact is that I need to do this insertion in many documents. The case is that following (I need insert a roles array for every…
Lucas Batistussi
  • 2,283
  • 3
  • 27
  • 35