Recent content by zorro

  1. Z

    Loop Running Time: O(n) Not O(n2)

    That does not work with duplicates.
  2. Z

    Loop Running Time: O(n) Not O(n2)

    So this is a comparison based sort, right?
  3. Z

    Loop Running Time: O(n) Not O(n2)

    I tried the output for 1 3 4 2 0 and found that the While loop executes 4 times only for i=0, it doesn't execute for other i's. The output was sorted. This of course took O(n) time. Isn't the worst case complexity of comparison based sorting algorithms O(nlogn)?
  4. Z

    Loop Running Time: O(n) Not O(n2)

    Can someone explain why the running time of following piece of pseudo code is O(n) and not O(n2)? for i := 0 to n - 1 while A[A[i]] != A[i] swap(A[i], A[A[i]]) end while end for The for loop executes at most n times and the inner while loop executes at most n-1 times...
  5. Z

    Why Does One C Hash Table Implementation Fail While the Other Succeeds?

    Can some one explain me the difference between the following two pieces of code ? First one doesn't work. I debugged it and made it to work but I am unable to understand how. The lines with changes have been made red bold.#include <stdio.h> #include <string.h> #include <stdlib.h> #define SIZE...
  6. Z

    What updates can we expect for the new PF website style?

    Bad Design! Poor design. Looks like those adware websites. Earlier look was classy.
  7. Z

    Sparse Matrix using linked list of a linked list

    firstcell is a pointer to the first non zero valued cellnode. Thank you! I did not know that.
  8. Z

    Sparse Matrix using linked list of a linked list

    I got my code working. Below if the final version. If I need to improve on something please let me know. #include <stdio.h> #define MAX 20 static struct cellnode *a[MAX]; static int k=0; struct cellnode { int val; int col; struct cellnode *nextcell; }; struct rownode...
  9. Z

    Sparse Matrix using linked list of a linked list

    This is an assignment, and my professors won't help. I just used one global variable head2. That's how we did in class for a single linked list. Here we have a single linked list of rownodes. Attached is the .txt file containing input matrix. Every time the end of a row is reached, i.e. a...
  10. Z

    Sparse Matrix using linked list of a linked list

    I modified my program as per your suggestion. It works pretty good before the display() function is called, where it gives a segmentation fault. I spent hours debugging it but came up with no error. #include <stdio.h> #define MAX 20 static struct cellnode *a[MAX]; static int k=0;struct...
  11. Z

    Sparse Matrix using linked list of a linked list

    I hope you understood my problem. In the following code snippet: void link2(int r){ struct rownode *temp,*new; new=create_rownode(); new->row=r; new->firstcell=head1; new->nextrow=NULL;... the firstcell of the newly created node should point to the first non zero valued node of the...
  12. Z

    Sparse Matrix using linked list of a linked list

    Isn't the firstcell of row node structure itself a head pointer to the first non-zero valued node of cell node?
  13. Z

    Sparse Matrix using linked list of a linked list

    Homework Statement The idea is to create following type of structure: first_row_with_a_nonzero_cell->next_row_with_a_nonzerocell->...->NULL rowN_with_a_nonzerocell->firstnonzerocolinrowN->nextnonzerocolinrowN...->NULL Input file is a 20x50 sparse matrix. The only problem I have is...
  14. Z

    Why Is the Fourier Sine Series Not Defined at Discontinuous Points?

    Why is Fourier sine series of any function satisfying Dirichlet's theorem, not defined on the discontinuous points whereas we define it for Fourier cosine series? ex - sine series of f(x) = cosx, 0<=x<=∏ is defined on 0<x<∏ whereas cosine series of f(x) = sinx, 0<=x<=∏ is defined on 0<=x<=∏
Back
Top