How come I can still access nodes after deleting an entire linked list?

Following is a function for deleting the entire list by accessing the head pointer to the 1st node: void deleteList(Node *head) { while (head != nullptr) { Node *temp = head; head = head->next; delete temp; } } Detailed program: struct Node { int data; Node* next; }; void traverseList(Node* head) { while (head !=… Read More How come I can still access nodes after deleting an entire linked list?

why a python function still returns "None" though i am explicitly returning a value?

def binarySearch(nums,low,high,target): if low<=high: mid=(low+high)//2 if nums[mid]==target: return mid if nums[mid]<target: binarySearch(nums,mid+1,high,target) else: binarySearch(nums,low,mid-1,target) else: return -1 def search(nums, target): return binarySearch(nums,0,len(nums)-1,target) nums=[-1,0,3,5,9,12] target=9 print(search(nums,target)) console output Expected output of the above python code for binary search is ‘4’. But my output is ‘None’. I also printed the value of mid on console output just… Read More why a python function still returns "None" though i am explicitly returning a value?

Error while finding the running sum of an array in C++ using vectors

Why am i getting this error, while finding the running sum of an array in c++? Line 1034: Char 34: runtime error: addition of unsigned offset to 0x6020000000b0 overflowed to 0x6020000000ac (stl_vector.h) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /usr/bin/../lib/gcc/x86_64-linux-gnu/9/../../../../include/c++/9/bits/stl_vector.h:1043:34". the code is: class Solution { public: vector<int> runningSum(vector<int>& nums) { vector<int> temp(nums.size()); nums[0]=temp[0]; for(int i=0;i<nums.size();i++){ temp[i]=temp[i-1]+nums[i]; } return… Read More Error while finding the running sum of an array in C++ using vectors

how to specify data on pearson correlation heatmap?

I have a pearson correlation heat map coded, but its showing data from my dataframe which i dont need. is there a way to specify which columns i’d like to include? thanks in advance sb.heatmap(df[‘POPDEN’, ‘RoadsArea’, ‘MedianIncome’, ‘MedianPrice’, ‘PropertyCount’, ‘AvPTAI2015’, ‘PTAL’].corr(), annot=True, fmt=’.2f’) ————————————————————————— TypeError Traceback (most recent call last) <ipython-input-54-832fc3c86e3e> in <module> —-> 1… Read More how to specify data on pearson correlation heatmap?