IQueryable and ISession [closed] - linq

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
Which way is better to use?
ISession session = SessionController.Factory.OpenSession();
IQueryable<myObject> myObjectdquery;
1.
myObjectquery = session.Query<myObject>();
myObjectquery = myObjectquery.Where(x=>x....)
or
2.
myObjectquery = session.Query<myObject>().Where(x=>x...);
I'm not sure is my logic correct but in first approach myObjectquery is first "filled" with data and then queried, and in second approach one step is skipped and myObjectquery is filled only with necessary data. The point is what is faster?

1.
myObjectquery = session.Query();
myObjectquery =
myObjectquery.Where(x=>x....) or
2.
myObjectquery = session.Query().Where(x=>x...);
They are exactly the same thing, just look at it. If you already know that and want to chose which one to go with, go with number 2, it's easier to ready and you have fewer code lines.
P.S: Your query is 'filled' with data in 1st example, but not in memory, so it doesn't matter. So yeah, it's the same thing.

Related

What is a most optimal way to merge and sort 2 sets? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 months ago.
Improve this question
So, say you have 2 sets with unknown properties. So the order and the size of each set is unknown. How would we merge and sort these 2 sets into one set?
The solution I have is to simply add the 2 sets into one set and perform a merge sort.
I feel as if there is a better way. Does anyone have any ideas?
Typically you would concatenate the sets and then sort them as a single set, that is almost as simple as it gets. I'm guessing you are using Python for this if that's the case you can use function sorted().

Is it necessary to memorize the codes of data structures? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
Is it necessary to memorize the code of data structures like linked lists, dynamic arrays , circular linked list, queues , stacks , Graphs etc. Or just the basic knowledge of code is enough ? What kind of questions can be asked in a job interview regarding data structures ?
I don't know what your (future) employer may ask, but generally, I'd say no. You have to know how they work and what they're used for, expecially which data structure serves which purpose with its advantages/disadvantages. If you know that, you'll be able to write the code of such a structure without having it memorized - because you know how it will work.

What takes less time to complete, comparing two variables, or assigning a new value to a variable? [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 6 years ago.
Improve this question
Basically what I'm saying is, which operation takes less time to complete? I know the time it takes to complete 1 of these operations is too fast to measure, but I would assume that there would be some way to explain what happens that could explain which one is faster.
Also, I would assume that comparing two variables would be more taxing on the CPU and assigning a value would be more RAM taxing. Is that correct?
In American football, this would be like asking which is faster:
A running play?
A passing play?
It's too vague, too general to have any kind of sensible answer.

how to efficiently work through algorithms on paper [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am currently reading a programming text book and as I discover different algorithms used in the book I'm finding it necessary to understand how they work by working through them. Is there a standard & efficient way to work through simple algorithms on paper?
Write the algorithm down on the paper. Write the corresponding graphs and variables that you use in algorithm.
Now follow algorithm step by step and note what changed with variables and graphs etc.
Time slices. Make a table, where the column headers are variables involved, and row headers are step numbers. Fill in row zero with initial values if any, and each row represents the result of the current step on the previous row.

Which data structure will always run half the size of an array when implemented recursively? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I had this question on my exam today.
Choices were: 1)Merge sort 2)Quick sort 3)insertion sort 4)bubble sort 5)selection sort
I had a feeling that the answer is either 1 or 2, but I don't know which one it is. It seems merge sort and quick sort wouldn't stop at the middle. Can someone explain the reason of the answer you pick?
The merge sort is called with (i.e. sorts) half the data on each recursive call. The data need not be duplicated, however.

Resources