Search Results

Search found 11 results on 1 pages for 'ageek'.

Page 1/1 | 1 

  • What's wrong in this C program..? [closed]

    - by AGeek
    struct bucket { int nStrings; //No. of Strings in a Bucket. char strings[MAXSTRINGS][MAXWORDLENGTH]; // A bucket row can contain maximum 9 strings of max string length 10. };//buck[TOTBUCKETS]; void lexSorting(char array[][10], int lenArray, int symb) //symb - symbol, sorting based on character symbols. { int i, j; int bucketNo; int tBuckNStrings; bucket buck[TOTBUCKETS]; for(i=0; i<lenArray; i++) { bucketNo = array[i][symb] - 'a'; // Find Bucket No. in which the string is to be placed. tBuckNStrings = buck[bucketNo].nStrings; // temp variable for storing nStrings var in bucket structure. strcpy(buck[bucketNo].strings[tBuckNStrings],array[i]); // Store the string in its bucket. buck[bucketNo].nStrings = ++tBuckNStrings; //Increment the nStrings value of the bucket. } // lexSorting(array, lenArray, ++symb); printf("****** %d ******\n", symb); for(i=0; i<TOTBUCKETS; i++) { printf("%c = ", i+'a'); for(j=0; j<buck[i].nStrings; j++) printf("%s ",buck[i].strings[j]); printf("\n"); } } int main() { char array[][10] = {"able","aback","a","abet","acid","yawn","yard","yarn","year","yoke"}; int lenArray = 10; int i; printf("Strings: "); for(i=0; i<lenArray; i++) printf("%s ",array[i]); printf("\n"); lexSorting(array, lenArray, 0); } Well here is the complete code, that I am trying. since its been a long time since i have touched upon C programming, so somewhere i am making mistake in structure declaration. The problem goes here:- 1) I have declared a structure above and its object as array(buck[]). 2) Now when I declare this object array along with the structure, it works fine.. I have commented this thing right now. 3) But when I declare this object array inside the function.. because ultimately i have to declare inside function( as i need to build a recursive program, where objects will be created in very recursive call) then the program is throwing segmentation fault. Expected Output > [others@centos htdocs]$ ./a.out > Strings: able aback a abet acid yawn > yard yarn year yoke > ****** 0 ****** > a = able aback a abet acid > b = > c > . > . > y = yawn yard yarnyear yoke > z = Actual Output [others@centos htdocs]$ ./a.out Strings: able aback a abet acid yawn yard yarn year yoke Segmentation fault I have no idea, what difference I made in this. Kindly help. Thanks.

    Read the article

  • Data Structure for a particular problem??

    - by AGeek
    Hi, Which data structure can perform insertion, deletion and searching operation in O(1) time in the worst case. We may assume the set of elements are integers drawn from a finite set 1,2,...,n, and initialization can take O(n) time. I can only think of implementing a hash table. Implementing it with Trees will not give O(1) time complexity for any of the operation. Or is it possible?? Kindly share your views on this, or any other data structure apart from these.. Thanks..

    Read the article

  • Question on Binary Search Trees.

    - by AGeek
    Hi, I was thinking of implementing a binary search trees. I have implemented some very basic operations such as search, insert, delete. Please share your experiences as to what all other operations i could perform on binary search trees, and some real time operations(basic) that is needed every time for any given situation.. I hope my question was clear.. Thanks.

    Read the article

  • How can i assign a two dimensional array into other temporary two dimensional array.....?? in C Programming..

    - by AGeek
    Hi I am trying to store the contents of two dimensional array into a temporary array.... How is it possible... I don't want looping over here, as it would add an extra overhead.. Any pointer notation would be good. struct bucket { int nStrings; char strings[MAXSTRINGS][MAXWORDLENGTH]; }; void func() { char **tArray; int tLenArray = 0; for(i=0; i<TOTBUCKETS-1; i++) { if(buck[i].nStrings != 0) { tArray = buck[i].strings; tLenArray = buck[i].nStrings; } } } The error here i am getting is:- [others@centos htdocs]$ gcc lexorder.c lexorder.c: In function âlexSortingâ: lexorder.c:40: warning: assignment from incompatible pointer type Please let me know if this needs some more explanaition...

    Read the article

  • Oracle Triggers Query..

    - by AGeek
    Lets consider a Table STUD and a ROW-Level TRIGGER is implemented over INSERT query.. My scenario goes like this, whenever a row is inserted, a trigger is fired and it should access some script file which is placed in the hard disk, and ultimately should print the result. So, is this thing is possible? and if yes, then this thing should exist in dynamic form, i.e. if we change the content of script file, then the oracle should reflect those changes as well. I have tried doing this for java using External Procedures, but doesn't feel that much satisfied with the result that i wanted. Kindly give your point-of-view for this kind of scenario and ways that this can be implemented.

    Read the article

  • Result of Long Positive Integers & Search and element in array..

    - by AGeek
    Hi, I have two Questions for which I cannot find answers by googling, but I find these questions very important for preparation.. Kindly explain only the logic, I will be able to code. In Search of Efficient Logic..... in terms of Memory and Time. WAP to add two long positive integers. What Data structure / data type we can use to store the numbers and result. What is the best way to search an element from an array in shortest time. Size of the array could be large enough, and any elements could be stored in the array(i.e. no range). Thanks.

    Read the article

  • Balanced Search Tree Query, Asymtotic Analysis..

    - by AGeek
    Hi, The situation is as follows:- We have n number and we have print them in sorted order. We have access to balanced dictionary data structure, which supports the operations serach, insert, delete, minimum, maximum each in O(log n) time. We want to retrieve the numbers in sorted order in O(n log n) time using only the insert and in-order traversal. The answer to this is:- Sort() initialize(t) while(not EOF) read(x) insert(x,t); Traverse(t); Now the query is if we read the elements in time "n" and then traverse the elements in "log n"(in-order traversal) time,, then the total time for this algorithm (n+logn)time, according to me.. Please explain the follow up of this algorithm for the time calculation.. How it will sort the list in O(nlogn) time?? Thanks.

    Read the article

  • Algorithm Question.. Linked List..

    - by AGeek
    Hi, Scenario is as follows:- I want to reverse the direction of the singly linked list, In other words, after the reversal all pointers should now point backwards.. Well the algorithm should take linear time. The solution that i have thought of using another datastructure A Stack.. With the help of which the singly linked list would be easily reversed, with all pointers pointing backwards.. But i am in doubt, that whether the following implementation yeild linear time complexity.. Please comment on this.. And if any other efficient algorithm is in place, then please discuss.. Thanks.

    Read the article

  • Database(Partitions) related query.... Please suggest..........

    - by AGeek
    The Query is as follows:- We have an oracle schema, with tables partitioned. -- Need to make one of the partition offline. (How to achieve this,, or have thought of assigning each partition, a different tablespace, and then making that tablespace offline) any other way out possible so as to avoid making so many tablespaces???? -- Then, copy the data files/ logs related to that partition to the temporary storage..... how to achieve this thing... any docs related to the same.... -- Then We make this partition / related tablespace online... -- Then we create a second schema with the same tables as above..... -- Copy the partition data from temporary storage to this table. (How this can be achieved,,, any specific doc??? -- Then verifying to the data is accessible in all respects..... If possible, let's discuss to find out the solution........ Thanks....

    Read the article

  • Array Related Doubt.......

    - by AGeek
    I have the following program........... int insert(int *array, int arraySize, int newElement) { array[arraySize + 1] = newElement; return (arraySize+1); // Return new Array size...... } int main() { int array[] = {1,2,3,4,5}; int arraySize = sizeof(array) / sizeof(int); insertInArray(array, arraySize,6); print(array); } I am trying to work out this program in C programming language... But when i print the array after insertion,,, it doesn't prints the desired output which is needed.. Please correct me if i am doing something wrong..... Thanks..

    Read the article

1